diff options
author | Christopher Faylor <me@cgf.cx> | 2012-06-03 20:31:33 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2012-06-03 20:31:33 +0400 |
commit | 7c15768aa5f2858aca06f0001f7b5b271c34b163 (patch) | |
tree | 12a9fb1e195a2b8ba2e67a8f60f02c53f752611b /winsup/cygwin/select.cc | |
parent | 00a312432556e607a16d880932c544f314f7e09e (diff) |
* select.cc (cygwin_select): Make sure that we only return -1 as an error
return.
(select_stuff::wait): Semi-revert to previous method for filling out w4.
Diffstat (limited to 'winsup/cygwin/select.cc')
-rw-r--r-- | winsup/cygwin/select.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index ad78cc228..b9f79e8b5 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -198,6 +198,8 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, } } + if (res < -1) + res = -1; syscall_printf ("%R = select(%d, %p, %p, %p, %p)", res, maxfds, readfds, writefds, exceptfds, to); return res; @@ -315,7 +317,7 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, if ((w4[m] = pthread::get_cancel_event ()) != NULL) m++; - int startfds = m; + DWORD startfds = m; /* Loop through the select chain, starting up anything appropriate and counting the number of active fds. */ while ((s = s->next)) @@ -331,11 +333,13 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, return select_error; } if (s->h != NULL) - for (DWORD i = startfds; i <= m; i++) - if (i == m) - w4[m = i] = s->h; - else if (w4[i] == s->h) - break; + { + for (DWORD i = startfds; i < m; i++) + if (w4[i] == s->h) + goto next_while; + w4[m++] = s->h; + } +next_while:; } debug_printf ("m %d, ms %u", m, ms); |