From 986da7853d68e173d6f48f6a3cfe15df41ad084f Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 8 Dec 2011 06:49:56 +0000 Subject: [PATCH] * select.cc (cygwin_select): Make sure that poll is called when appropriate. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/select.cc | 42 +++++++++++++++++------------------------ 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 329d163b3..9ab00e78b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2011-12-08 Christopher Faylor + + * select.cc (cygwin_select): Make sure that poll is called when + appropriate. + 2011-12-08 Christopher Faylor * dll_init.cc (dll_dllcrt0): Don't try to initialize dll data if we're diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index c60cd225f..52714a060 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -124,7 +124,6 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, select_printf ("sel.always_ready %d", sel.always_ready); - int timeout = 0; /* Allocate some fd_set structures using the number of fds as a guide. */ fd_set *r = allocfd_set (maxfds); fd_set *w = allocfd_set (maxfds); @@ -133,34 +132,27 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, int res = 1; /* Degenerate case. No fds to wait for. Just wait. */ if (sel.start.next == NULL) - { - switch (cygWFMO (0, ms)) - { - case WAIT_OBJECT_0: - select_printf ("signal received"); - set_sig_errno (EINTR); - return -1; - case WAIT_OBJECT_0 + 1: - sel.destroy (); - pthread::static_cancel_self (); - /*NOTREACHED*/ - default: - break; - } - res = 0; - } - else if (sel.always_ready || ms == 0) - res = 0; - else if ((timeout = sel.wait (r, w, e, ms) < 0)) - res = -1; /* some kind of error */ - - if (res >= 0) + switch (cygWFMO (0, ms)) + { + case WAIT_OBJECT_0: + select_printf ("signal received"); + set_sig_errno (EINTR); + res = -1; + case WAIT_OBJECT_0 + 1: + sel.destroy (); + pthread::static_cancel_self (); + /*NOTREACHED*/ + default: + res = 0; + break; + } + else if ((sel.always_ready || ms == 0) + || (res = sel.wait (r, w, e, ms)) == 0) { copyfd_set (readfds, r, maxfds); copyfd_set (writefds, w, maxfds); copyfd_set (exceptfds, e, maxfds); - if (res > 0) - res = sel.poll (readfds, writefds, exceptfds); + res = sel.poll (readfds, writefds, exceptfds); } syscall_printf ("%R = select (%d, %p, %p, %p, %p)", res, maxfds, readfds,