From 20ddde2f552afedf7ef662bb21fec7a56f50040f Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 11 Jan 2016 10:36:33 +0100 Subject: [PATCH] select(2): Drop checking descriptors in case of immediate timeout. * select.cc (select): Call sel.poll only if sel.wait returned select_ok. Signed-off-by: Corinna Vinschen --- winsup/cygwin/select.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index b4c37783a..fa6859c59 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -189,12 +189,17 @@ select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, UNIX_FD_ZERO (readfds, maxfds); UNIX_FD_ZERO (writefds, maxfds); UNIX_FD_ZERO (exceptfds, maxfds); - /* Set bit mask from sel records even in case of a timeout so we - don't miss one. This also sets ret to the right value >= 0, - matching the number of bits set in the fds records. */ - ret = sel.poll (readfds, writefds, exceptfds); - if (!ret && res != select_stuff::select_set_zero) - res = select_stuff::select_loop; + if (res == select_stuff::select_set_zero) + ret = 0; + else + { + /* Set bit mask from sel records. This also sets ret to the + right value >= 0, matching the number of bits set in the + fds records. if ret is 0, continue to loop. */ + ret = sel.poll (readfds, writefds, exceptfds); + if (!ret) + res = select_stuff::select_loop; + } } /* Always clean up everything here. If we're looping then build it all up again. */