aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-08-27 15:59:26 +0000
committerChristopher Faylor <me@cgf.cx>2001-08-27 15:59:26 +0000
commit8d661d3658a9f861f66bb4b334019538dfedadd9 (patch)
tree724d3fc501adefa70864de36c8d13a4ef38c3879 /winsup/cygwin
parentc2f0f4f466948659e2688193a03508512a199805 (diff)
downloadnewlib-8d661d3658a9f861f66bb4b334019538dfedadd9.zip
newlib-8d661d3658a9f861f66bb4b334019538dfedadd9.tar.gz
newlib-8d661d3658a9f861f66bb4b334019538dfedadd9.tar.bz2
* select.cc (cygwin_select): Ensure that arguments are zeroed on timeout.
(select_stuff::wait): Ditto.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/select.cc26
2 files changed, 20 insertions, 12 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index c7c4c1e..25752aa 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+Mon Aug 27 11:58:19 2001 Christopher Faylor <cgf@cygnus.com>
+
+ * select.cc (cygwin_select): Ensure that arguments are zeroed on
+ timeout.
+ (select_stuff::wait): Ditto.
+
2001-08-24 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
* syscalls.cc (check_tty_fds): New function. Check whether there is a
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index cfccd85..42762ba 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -159,6 +159,12 @@ 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);
+ fd_set *e = allocfd_set (maxfds);
+
/* Degenerate case. No fds to wait for. Just wait. */
if (sel.start.next == NULL)
{
@@ -168,23 +174,17 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
set_sig_errno (EINTR);
return -1;
}
- return 0;
+ timeout = 1;
}
-
- /* 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);
- fd_set *e = allocfd_set (maxfds);
-
- if (sel.always_ready || ms == 0)
+ else if (sel.always_ready || ms == 0)
/* Don't bother waiting. */;
- else if (sel.wait (r, w, e, ms))
+ else if ((timeout = sel.wait (r, w, e, ms) < 0))
return -1; /* some kind of error */
copyfd_set (readfds, r, maxfds);
copyfd_set (writefds, w, maxfds);
copyfd_set (exceptfds, e, maxfds);
- return sel.poll (readfds, writefds, exceptfds);
+ return timeout ? 0 : sel.poll (readfds, writefds, exceptfds);
}
/* Cleanup */
@@ -254,6 +254,7 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
HANDLE w4[MAXIMUM_WAIT_OBJECTS];
select_record *s = &start;
int m = 0;
+ int res = 0;
w4[m++] = signal_arrived; /* Always wait for the arrival of a signal. */
/* Loop through the select chain, starting up anything appropriate and
@@ -302,6 +303,7 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
return -1;
case WAIT_TIMEOUT:
select_printf ("timed out");
+ res = 1;
goto out;
}
@@ -338,8 +340,8 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
}
out:
- select_printf ("returning 0");
- return 0;
+ select_printf ("returning %d", res);
+ return res;
}
static int