mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-14 15:40:19 +02:00
Update Gnulib to 6835fc458f30b94f15d69c35a79cbc2dfabe2d06.
This commit is contained in:
parent
bfca4367b0
commit
2b421e02e1
412 changed files with 5156 additions and 2314 deletions
38
lib/select.c
38
lib/select.c
|
@ -1,7 +1,7 @@
|
|||
/* Emulation for select(2)
|
||||
Contributed by Paolo Bonzini.
|
||||
|
||||
Copyright 2008-2014 Free Software Foundation, Inc.
|
||||
Copyright 2008-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of gnulib.
|
||||
|
||||
|
@ -82,9 +82,11 @@ typedef DWORD (WINAPI *PNtQueryInformationFile)
|
|||
#define PIPE_BUF 512
|
||||
#endif
|
||||
|
||||
/* Optimized test whether a HANDLE refers to a console.
|
||||
See <http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00065.html>. */
|
||||
#define IsConsoleHandle(h) (((intptr_t) (h) & 3) == 3)
|
||||
static BOOL IsConsoleHandle (HANDLE h)
|
||||
{
|
||||
DWORD mode;
|
||||
return GetConsoleMode (h, &mode) != 0;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
IsSocketHandle (HANDLE h)
|
||||
|
@ -252,6 +254,7 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
|
|||
DWORD ret, wait_timeout, nhandles, nsock, nbuffer;
|
||||
MSG msg;
|
||||
int i, fd, rc;
|
||||
clock_t tend;
|
||||
|
||||
if (nfds > FD_SETSIZE)
|
||||
nfds = FD_SETSIZE;
|
||||
|
@ -388,6 +391,10 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
|
|||
/* Place a sentinel at the end of the array. */
|
||||
handle_array[nhandles] = NULL;
|
||||
|
||||
/* When will the waiting period expire? */
|
||||
if (wait_timeout != INFINITE)
|
||||
tend = clock () + wait_timeout;
|
||||
|
||||
restart:
|
||||
if (wait_timeout == 0 || nsock == 0)
|
||||
rc = 0;
|
||||
|
@ -408,6 +415,16 @@ restart:
|
|||
wait_timeout = 0;
|
||||
}
|
||||
|
||||
/* How much is left to wait? */
|
||||
if (wait_timeout != INFINITE)
|
||||
{
|
||||
clock_t tnow = clock ();
|
||||
if (tend >= tnow)
|
||||
wait_timeout = tend - tnow;
|
||||
else
|
||||
wait_timeout = 0;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
ret = MsgWaitForMultipleObjects (nhandles, handle_array, FALSE,
|
||||
|
@ -453,7 +470,16 @@ restart:
|
|||
}
|
||||
}
|
||||
|
||||
if (rc == 0 && wait_timeout == INFINITE)
|
||||
if (rc == 0
|
||||
&& (wait_timeout == INFINITE
|
||||
/* If NHANDLES > 1, but no bits are set, it means we've
|
||||
been told incorrectly that some handle was signaled.
|
||||
This happens with anonymous pipes, which always cause
|
||||
MsgWaitForMultipleObjects to exit immediately, but no
|
||||
data is found ready to be read by windows_poll_handle.
|
||||
To avoid a total failure (whereby we return zero and
|
||||
don't wait at all), let's poll in a more busy loop. */
|
||||
|| (wait_timeout != 0 && nhandles > 1)))
|
||||
{
|
||||
/* Sleep 1 millisecond to avoid busy wait and retry with the
|
||||
original fd_sets. */
|
||||
|
@ -463,6 +489,8 @@ restart:
|
|||
SleepEx (1, TRUE);
|
||||
goto restart;
|
||||
}
|
||||
if (timeout && wait_timeout == 0 && rc == 0)
|
||||
timeout->tv_sec = timeout->tv_usec = 0;
|
||||
}
|
||||
|
||||
/* Now fill in the results. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue