poll: do not return 0 on timeout=-1
authorErik Faye-Lund <kusmabite@gmail.com>
Wed, 6 Jul 2011 10:10:51 +0000 (12:10 +0200)
committerEric Blake <eblake@redhat.com>
Wed, 6 Jul 2011 16:27:13 +0000 (10:27 -0600)
* lib/poll.c: Loop with yield if no events occured

ChangeLog
lib/poll.c

index e1ed452..a0bfe36 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-07-06  Erik Faye-Lund  <kusmabite@gmail.com>
+
+       poll: do not return 0 on timeout=-1
+       * lib/poll.c: Loop with yield if no events occured
+
 2011-07-06  Eric Blake  <eblake@redhat.com>
 
        pthread_sigmask: always replace when not using pthread
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
 }