Fix blocking in run loop.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@12567 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2002-02-20 06:42:05 +00:00
parent c7b827b21e
commit 36dd6aad2f
21 changed files with 85 additions and 16 deletions

View file

@ -8,6 +8,8 @@
invocation is retaining its contents.
* configure.in: Disable ffi and warn about it.
* configure: regenerated
* Source/NSRunLoop.m: ([acceptInputForMode:beforeDate:]) block until
limit date even if no I/O is possible.
2002-02-13 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -65,7 +65,9 @@
#include <limits.h>
#include <string.h> // for strstr()
#include <sys/stat.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>

View file

@ -38,7 +38,9 @@
#include <Foundation/NSDebug.h>
#include <Foundation/GSMime.h>
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/file.h>
#ifdef HAVE_SYS_FCNTL_H

View file

@ -41,7 +41,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#if HAVE_UNISTD_H
#include <unistd.h> /* for gethostname() */
#endif
#ifndef __MINGW__
#include <sys/param.h> /* for MAXHOSTNAMELEN */

View file

@ -65,7 +65,9 @@
#endif
#include <netdb.h>
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <errno.h>
// Maximum data in single I/O operation

View file

@ -49,7 +49,9 @@
#include <Foundation/NSFileManager.h>
#include <Foundation/NSPathUtilities.h>
#include <Foundation/NSValue.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
@interface NSObject (PrivateFrameworks)

View file

@ -79,7 +79,9 @@
#include <Foundation/NSZone.h>
#include <stdio.h>
#include <string.h> /* for memset() */
#if HAVE_UNISTD_H
#include <unistd.h> /* SEEK_* on SunOS 4 */
#endif
#if HAVE_MMAP
#include <unistd.h>

View file

@ -56,7 +56,9 @@
# include <ndir.h>
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if HAVE_WINDOWS_H
# include <windows.h>
#endif

View file

@ -41,7 +41,9 @@
#include <winsock.h>
#else
#include <netdb.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>

View file

@ -26,7 +26,9 @@
#include <config.h>
#include <errno.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <base/preface.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSException.h>

View file

@ -40,7 +40,9 @@
#include <syslog.h>
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "GSUserDefaults.h"

View file

@ -32,7 +32,7 @@
#ifdef __WIN32__
#include <malloc.h>
#endif
#ifndef __MINGW__
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdio.h>

View file

@ -29,7 +29,9 @@
#include <Foundation/NSObject.h>
#include <Foundation/NSFileHandle.h>
#include <Foundation/NSDebug.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
@implementation NSPipe

View file

@ -56,7 +56,9 @@
#include <config.h>
#include <base/preface.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_STRERROR
#include <errno.h>

View file

@ -50,6 +50,9 @@
#if HAVE_POLL_H
#include <poll.h>
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <time.h>
#include <limits.h>
#include <string.h> /* for memset() */
@ -565,10 +568,6 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
unsigned i;
i = GSIArrayCount(watchers);
if (i == 0)
{
return NO;
}
/*
* Get ready to listen to file descriptors.
@ -879,14 +878,10 @@ if (0) {
fd_set exception_fds; // Mask for exception fds.
fd_set write_fds; // Mask for write-ready fds.
int num_inputs = 0;
int fdEnd = 0;
int fdEnd = -1;
unsigned i;
i = GSIArrayCount(watchers);
if (i == 0)
{
return NO;
}
/* Find out how much time we should wait, and set SELECT_TIMEOUT. */
if (milliseconds == 0)
@ -1013,6 +1008,7 @@ if (0) {
timeout.tv_usec = 0;
select_timeout = &timeout;
}
select_return = select (fdEnd, &read_fds, &write_fds,
&exception_fds, select_timeout);
@ -1839,9 +1835,10 @@ if (0) {
/**
* Listen to input sources.<br />
* If limit_date is nil, then don't wait; just poll inputs and return,
* otherwise block until input is available or until all input limit dates
* have passed (whichever comes first).<br />
* If limit_date is nil or in the past, then don't wait;
* just poll inputs and return,
* otherwise block until input is available or until the
* earliest limit date has passed (whichever comes first).<br />
* If the supplied mode is nil, uses NSDefaultRunLoopMode.
*/
- (void) acceptInputForMode: (NSString*)mode
@ -1869,9 +1866,45 @@ if (0) {
if (context == nil || (watchers = context->watchers) == 0
|| (i = GSIArrayCount(watchers)) == 0)
{
GSCheckTasks();
GSNotifyASAP();
NSDebugMLLog(@"NSRunLoop", @"no inputs in mode %@", mode);
GSNotifyASAP();
GSNotifyIdle();
ti = [limit_date timeIntervalSinceNow];
/*
* Pause for as long as possible (up to the limit date)
*/
if (ti > 0.0)
{
#if defined(HAVE_USLEEP)
if (ti >= INT_MAX / 1000000)
{
ti = INT_MAX;
}
else
{
ti *= 1000000;
}
usleep (ti);
#elif defined(__MINGW__)
if (ti >= INT_MAX / 1000)
{
ti = INT_MAX;
}
else
{
ti *= 1000;
}
Sleep (ti);
#else
sleep (ti);
#endif
}
GSCheckTasks();
if (context != nil)
{
[self _checkPerformers: context];
}
GSNotifyASAP();
_currentMode = savedMode;
RELEASE(arp);
NS_VOIDRETURN;

View file

@ -67,7 +67,9 @@
#include <base/GSFormat.h>
#include <limits.h>
#include <sys/stat.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>

View file

@ -45,7 +45,9 @@
#include <Foundation/NSDebug.h>
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#ifdef __FreeBSD__
#include <fcntl.h>

View file

@ -32,7 +32,9 @@
#include <config.h>
#include <base/preface.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <Foundation/NSThread.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSString.h>

View file

@ -40,7 +40,7 @@
#include <Foundation/NSUserDefaults.h>
#include <stdlib.h> // for getenv()
#if !defined(__WIN32__)
#if HAVE_UNISTD_H
#include <unistd.h> // for getlogin()
#endif
#if HAVE_PWD_H

View file

@ -59,7 +59,9 @@
#endif
#include <netdb.h>
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <errno.h>
/*

View file

@ -43,7 +43,9 @@
#include <sys/file.h>
#include <sys/stat.h>
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <errno.h>
// Maximum data in single I/O operation