* select.cc (cygwin_select): Add some comments.

(select_stuff::wait): Ditto.
This commit is contained in:
Christopher Faylor 2012-06-03 03:29:47 +00:00
parent 45b61a88be
commit 00a3124325
2 changed files with 24 additions and 8 deletions

View File

@ -1,3 +1,8 @@
2012-06-02 Christopher Faylor <me.cygwin2012@cgf.cx>
* select.cc (cygwin_select): Add some comments.
(select_stuff::wait): Ditto.
2012-06-02 Christopher Faylor <me.cygwin2012@cgf.cx>
* DevNotes: Add entry cgf-000010.
@ -8,10 +13,11 @@
select_stuff::wait_states for loop control.
(select_stuff::cleanup): Avoid unneeded initialization.
(select_stuff::wait): Modify definition to return
select_stuff::wait_states. Eliminate is_cancelable. Don't element 1
of an array if it is a cancel handle. Remove loop. Rely on being
called from enclosing loop in cygwin_select. Remove time recalculation
when restarting. Try harder to always return from the bottom.
select_stuff::wait_states. Eliminate is_cancelable. Don't inspect
element 1 of an array if it is a cancel handle. Remove loop. Rely on
being called from enclosing loop in cygwin_select. Remove time
recalculation when restarting. Try harder to always return from the
bottom.
* select.h (select_stuff::wait_state): New enum.
(select_stuff::wait): Modify declaration to return
select_stuff::wait_states.

View File

@ -128,6 +128,8 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
while (res == select_stuff::select_loop)
{
/* Build the select record per fd linked list and set state as
needed. */
for (int i = 0; i < maxfds; i++)
if (!sel.test_and_set (i, readfds, writefds, exceptfds))
{
@ -161,20 +163,26 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
break;
}
else if (sel.always_ready || ms == 0)
res = 0;
res = 0; /* Catch any active fds via
sel.poll() below */
else
res = sel.wait (r, w, e, ms);
res = sel.wait (r, w, e, ms); /* wait for an fd to become
become active or time out */
if (res == select_stuff::select_timeout)
res = 0;
res = 0; /* No fd's were active. */
else if (res >= 0)
{
copyfd_set (readfds, r, maxfds);
copyfd_set (writefds, w, maxfds);
copyfd_set (exceptfds, e, maxfds);
/* Actually set the bit mask from sel records */
res = (res == select_stuff::select_set_zero) ? 0 : sel.poll (readfds, writefds, exceptfds);
}
/* Always clean up everything here. If we're looping then build it
all up again. */
sel.cleanup ();
sel.destroy ();
/* Recalculate the time remaining to wait if we are going to be looping. */
if (res == select_stuff::select_loop && ms != INFINITE)
{
select_printf ("recalculating ms");
@ -350,6 +358,8 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
{
case WAIT_OBJECT_0:
select_printf ("signal received");
/* Need to get rid of everything when a signal occurs since we can't
be assured that a signal handler won't jump out of select entirely. */
cleanup ();
destroy ();
_my_tls.call_signal_handler ();
@ -358,7 +368,7 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
else
{
set_sig_errno (EINTR);
res = select_signalled;
res = select_signalled; /* Cause loop exit in cygwin_select */
}
break;
case WAIT_FAILED: