bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lib/poll.c bug?


From: Erik Faye-Lund
Subject: lib/poll.c bug?
Date: Wed, 29 Jun 2011 19:31:47 +0200

POSIX says the following about poll "A value of 0 indicates that the
call timed out and no file descriptors have been selected.". My
interpretation is that a return value of 0 would be illegal when
timeout = -1.

But when I call poll(..., -1), it seems 0 is returned under some
conditions. Looking through the code, it seems that there isn't any
efforts to enforce this paragraph; perhaps the included patch is
appropriate?

This problem currently affects a feature-branch I have against Git for
Windows, where this cause a program not to consume input because it
assumes that poll(..., -1) cannot return 0. The patch fixes it for me.

diff --git a/lib/poll.c b/lib/poll.c
index 8ce68c0..4b91606 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -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,9 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
         rc++;
     }

+  if (!rc && timeout == INFTIM)
+    goto restart;
+
   return rc;
 #endif
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]