Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-08-27 19:59:26 +0400
committerChristopher Faylor <me@cgf.cx>2001-08-27 19:59:26 +0400
commit8d661d3658a9f861f66bb4b334019538dfedadd9 (patch)
tree724d3fc501adefa70864de36c8d13a4ef38c3879 /winsup/cygwin/select.cc
parentc2f0f4f466948659e2688193a03508512a199805 (diff)
* select.cc (cygwin_select): Ensure that arguments are zeroed on timeout.
(select_stuff::wait): Ditto.
Diffstat (limited to 'winsup/cygwin/select.cc')
-rw-r--r--winsup/cygwin/select.cc26
1 files changed, 14 insertions, 12 deletions
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index cfccd8563..42762baa5 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