From adc3a5b0083c935f5dcd408983e37c78cb8ebd7c Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 6 Jul 2011 12:10:51 +0200 Subject: [PATCH] poll: do not return 0 on timeout=-1 * lib/poll.c: Loop with yield if no events occured --- ChangeLog | 5 +++++ lib/poll.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index e1ed45284..a0bfe3640 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-07-06 Erik Faye-Lund + + poll: do not return 0 on timeout=-1 + * lib/poll.c: Loop with yield if no events occured + 2011-07-06 Eric Blake pthread_sigmask: always replace when not using pthread diff --git a/lib/poll.c b/lib/poll.c index 8ce68c015..e06456581 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,12 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout) rc++; } + if (!rc && timeout == INFTIM) + { + SwitchToThread(); + goto restart; + } + return rc; #endif } -- 2.11.0