* select.cc (cygwin_select): Add some comments.
(select_stuff::wait): Ditto.
This commit is contained in:
parent
45b61a88be
commit
00a3124325
@ -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>
|
2012-06-02 Christopher Faylor <me.cygwin2012@cgf.cx>
|
||||||
|
|
||||||
* DevNotes: Add entry cgf-000010.
|
* DevNotes: Add entry cgf-000010.
|
||||||
@ -8,10 +13,11 @@
|
|||||||
select_stuff::wait_states for loop control.
|
select_stuff::wait_states for loop control.
|
||||||
(select_stuff::cleanup): Avoid unneeded initialization.
|
(select_stuff::cleanup): Avoid unneeded initialization.
|
||||||
(select_stuff::wait): Modify definition to return
|
(select_stuff::wait): Modify definition to return
|
||||||
select_stuff::wait_states. Eliminate is_cancelable. Don't element 1
|
select_stuff::wait_states. Eliminate is_cancelable. Don't inspect
|
||||||
of an array if it is a cancel handle. Remove loop. Rely on being
|
element 1 of an array if it is a cancel handle. Remove loop. Rely on
|
||||||
called from enclosing loop in cygwin_select. Remove time recalculation
|
being called from enclosing loop in cygwin_select. Remove time
|
||||||
when restarting. Try harder to always return from the bottom.
|
recalculation when restarting. Try harder to always return from the
|
||||||
|
bottom.
|
||||||
* select.h (select_stuff::wait_state): New enum.
|
* select.h (select_stuff::wait_state): New enum.
|
||||||
(select_stuff::wait): Modify declaration to return
|
(select_stuff::wait): Modify declaration to return
|
||||||
select_stuff::wait_states.
|
select_stuff::wait_states.
|
||||||
|
@ -128,6 +128,8 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|||||||
|
|
||||||
while (res == select_stuff::select_loop)
|
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++)
|
for (int i = 0; i < maxfds; i++)
|
||||||
if (!sel.test_and_set (i, readfds, writefds, exceptfds))
|
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;
|
break;
|
||||||
}
|
}
|
||||||
else if (sel.always_ready || ms == 0)
|
else if (sel.always_ready || ms == 0)
|
||||||
res = 0;
|
res = 0; /* Catch any active fds via
|
||||||
|
sel.poll() below */
|
||||||
else
|
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)
|
if (res == select_stuff::select_timeout)
|
||||||
res = 0;
|
res = 0; /* No fd's were active. */
|
||||||
else if (res >= 0)
|
else if (res >= 0)
|
||||||
{
|
{
|
||||||
copyfd_set (readfds, r, maxfds);
|
copyfd_set (readfds, r, maxfds);
|
||||||
copyfd_set (writefds, w, maxfds);
|
copyfd_set (writefds, w, maxfds);
|
||||||
copyfd_set (exceptfds, e, 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);
|
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.cleanup ();
|
||||||
sel.destroy ();
|
sel.destroy ();
|
||||||
|
/* Recalculate the time remaining to wait if we are going to be looping. */
|
||||||
if (res == select_stuff::select_loop && ms != INFINITE)
|
if (res == select_stuff::select_loop && ms != INFINITE)
|
||||||
{
|
{
|
||||||
select_printf ("recalculating ms");
|
select_printf ("recalculating ms");
|
||||||
@ -350,6 +358,8 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|||||||
{
|
{
|
||||||
case WAIT_OBJECT_0:
|
case WAIT_OBJECT_0:
|
||||||
select_printf ("signal received");
|
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 ();
|
cleanup ();
|
||||||
destroy ();
|
destroy ();
|
||||||
_my_tls.call_signal_handler ();
|
_my_tls.call_signal_handler ();
|
||||||
@ -358,7 +368,7 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
set_sig_errno (EINTR);
|
set_sig_errno (EINTR);
|
||||||
res = select_signalled;
|
res = select_signalled; /* Cause loop exit in cygwin_select */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WAIT_FAILED:
|
case WAIT_FAILED:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user