summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/select.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/select.cc')
-rw-r--r--winsup/cygwin/select.cc22
1 files changed, 19 insertions, 3 deletions
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index e72e63b68..94326dc41 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -181,22 +181,34 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
else if ((timeout = sel.wait (r, w, e, ms) < 0))
return -1; /* some kind of error */
+ sel.cleanup ();
copyfd_set (readfds, r, maxfds);
copyfd_set (writefds, w, maxfds);
copyfd_set (exceptfds, e, maxfds);
return timeout ? 0 : sel.poll (readfds, writefds, exceptfds);
}
-/* Cleanup */
-select_stuff::~select_stuff ()
+/* Call cleanup functions for all inspected fds. Gets rid of any
+ executing threads. */
+void
+select_stuff::cleanup ()
{
select_record *s = &start;
select_printf ("calling cleanup routines");
while ((s = s->next))
if (s->cleanup)
- s->cleanup (s, this);
+ {
+ s->cleanup (s, this);
+ s->cleanup = NULL;
+ }
+}
+/* Destroy all storage associated with select stuff. */
+select_stuff::~select_stuff ()
+{
+ cleanup ();
+ select_record *s = &start;
select_record *snext = start.next;
select_printf ("deleting select records");
@@ -1375,6 +1387,7 @@ fhandler_socket::select_read (select_record *s)
s->verify = verify_true;
s->cleanup = socket_cleanup;
}
+ s->read_ready = saw_shutdown_read ();
s->read_selected = TRUE;
return s;
}
@@ -1390,6 +1403,7 @@ fhandler_socket::select_write (select_record *s)
s->verify = verify_true;
s->cleanup = socket_cleanup;
}
+ s->write_ready = saw_shutdown_write ();
s->write_selected = TRUE;
return s;
}
@@ -1405,6 +1419,8 @@ fhandler_socket::select_except (select_record *s)
s->verify = verify_true;
s->cleanup = socket_cleanup;
}
+ /* FIXME: Is this right? Should these be used as criteria for except? */
+ s->except_ready = saw_shutdown_write () || saw_shutdown_read ();
s->except_selected = TRUE;
return s;
}