X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fpoll.c;h=e06456581b5d8163e320b56e55195182e5ad9bc7;hb=17f0ec6;hp=aeb7a356fcbd05043f2c1523e5eaea725a577867;hpb=51c2a23373ee3583682e6faae3dc4f518bd03f04;p=gnulib.git diff --git a/lib/poll.c b/lib/poll.c index aeb7a356f..e06456581 100644 --- a/lib/poll.c +++ b/lib/poll.c @@ -1,7 +1,7 @@ /* Emulation for poll(2) Contributed by Paolo Bonzini. - Copyright 2001-2003, 2006-2010 Free Software Foundation, Inc. + Copyright 2001-2003, 2006-2011 Free Software Foundation, Inc. This file is part of gnulib. @@ -28,7 +28,10 @@ #include #include -#include "poll.h" + +/* Specification. */ +#include + #include #include #include @@ -312,10 +315,7 @@ compute_revents (int fd, int sought, fd_set *rfds, fd_set *wfds, fd_set *efds) #endif /* !MinGW */ int -poll (pfd, nfd, timeout) - struct pollfd *pfd; - nfds_t nfd; - int timeout; +poll (struct pollfd *pfd, nfds_t nfd, int timeout) { #ifndef WIN32_NATIVE fd_set rfds, wfds, efds; @@ -452,6 +452,7 @@ poll (pfd, nfd, timeout) if (!hEvent) hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); +restart: handle_array[0] = hEvent; nhandles = 1; FD_ZERO (&rfds); @@ -505,7 +506,7 @@ poll (pfd, nfd, timeout) if (sought) handle_array[nhandles++] = h; if (pfd[i].revents) - wait_timeout = 0; + timeout = 0; } } @@ -592,6 +593,12 @@ poll (pfd, nfd, timeout) rc++; } + if (!rc && timeout == INFTIM) + { + SwitchToThread(); + goto restart; + } + return rc; #endif }