poll: do not return 0 on timeout=-1
[gnulib.git] / lib / poll.c
index 8ce68c0..e064565 100644 (file)
@@ -452,6 +452,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
   if (!hEvent)
     hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
 
+restart:
   handle_array[0] = hEvent;
   nhandles = 1;
   FD_ZERO (&rfds);
@@ -592,6 +593,12 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
         rc++;
     }
 
+  if (!rc && timeout == INFTIM)
+    {
+      SwitchToThread();
+      goto restart;
+    }
+
   return rc;
 #endif
 }