X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fpoll.c;h=b012ba0350ae94a08d27fbeadf99e73bbb49f541;hb=e4015779cec51757b48977760375f3947d0201bd;hp=49c41591efee5f1bd556f1811245f494710668cd;hpb=aeb898d88cddc17cefc7738940b4917e9ee27933;p=gnulib.git diff --git a/lib/poll.c b/lib/poll.c index 49c41591e..b012ba035 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 @@ -40,6 +43,7 @@ # include # include # include +# include "msvc-nothrow.h" #else # include # include @@ -150,6 +154,8 @@ win32_compute_revents (HANDLE h, int *p_sought) if (avail) happened |= *p_sought & (POLLIN | POLLRDNORM); } + else if (GetLastError () == ERROR_BROKEN_PIPE) + happened |= POLLHUP; else { @@ -310,10 +316,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; @@ -450,6 +453,7 @@ poll (pfd, nfd, timeout) if (!hEvent) hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); +restart: handle_array[0] = hEvent; nhandles = 1; FD_ZERO (&rfds); @@ -503,7 +507,7 @@ poll (pfd, nfd, timeout) if (sought) handle_array[nhandles++] = h; if (pfd[i].revents) - wait_timeout = 0; + timeout = 0; } } @@ -590,6 +594,12 @@ poll (pfd, nfd, timeout) rc++; } + if (!rc && timeout == INFTIM) + { + SwitchToThread(); + goto restart; + } + return rc; #endif }