diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 191560829..79991bd36 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -625,13 +625,15 @@ class fhandler_socket: public fhandler_base void hclose (HANDLE) {close ();} - select_record *select_read (select_stuff *); - select_record *select_write (select_stuff *); - select_record *select_except (select_stuff *); void set_addr_family (int af) {addr_family = af;} int get_addr_family () {return addr_family;} void set_socket_type (int st) { type = st;} int get_socket_type () {return type;} + + /* select.cc */ + virtual select_record *select_read (select_stuff *) = 0; + virtual select_record *select_write (select_stuff *) = 0; + virtual select_record *select_except (select_stuff *) = 0; }; class fhandler_socket_inet: public fhandler_socket @@ -674,6 +676,11 @@ class fhandler_socket_inet: public fhandler_socket int ioctl (unsigned int cmd, void *); int fcntl (int cmd, intptr_t); + /* select.cc */ + select_record *select_read (select_stuff *); + select_record *select_write (select_stuff *); + select_record *select_except (select_stuff *); + /* from here on: CLONING */ fhandler_socket_inet (void *) {} @@ -772,6 +779,11 @@ class fhandler_socket_local: public fhandler_socket int __reg3 facl (int, int, struct acl *); int __reg2 link (const char *); + /* select.cc */ + select_record *select_read (select_stuff *); + select_record *select_write (select_stuff *); + select_record *select_except (select_stuff *); + /* from here on: CLONING */ fhandler_socket_local (void *) {} diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index ca2cd5ab2..86e7cd8fd 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -1549,7 +1549,7 @@ socket_cleanup (select_record *, select_stuff *stuff) } select_record * -fhandler_socket::select_read (select_stuff *ss) +fhandler_socket_inet::select_read (select_stuff *ss) { select_record *s = ss->start.next; if (!s->startup) @@ -1565,7 +1565,7 @@ fhandler_socket::select_read (select_stuff *ss) } select_record * -fhandler_socket::select_write (select_stuff *ss) +fhandler_socket_inet::select_write (select_stuff *ss) { select_record *s = ss->start.next; if (!s->startup) @@ -1586,7 +1586,61 @@ fhandler_socket::select_write (select_stuff *ss) } select_record * -fhandler_socket::select_except (select_stuff *ss) +fhandler_socket_inet::select_except (select_stuff *ss) +{ + select_record *s = ss->start.next; + if (!s->startup) + { + s->startup = start_thread_socket; + s->verify = verify_true; + s->cleanup = socket_cleanup; + } + s->peek = peek_socket; + /* 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; +} + +select_record * +fhandler_socket_local::select_read (select_stuff *ss) +{ + select_record *s = ss->start.next; + if (!s->startup) + { + s->startup = start_thread_socket; + s->verify = verify_true; + s->cleanup = socket_cleanup; + } + s->peek = peek_socket; + s->read_ready = saw_shutdown_read (); + s->read_selected = true; + return s; +} + +select_record * +fhandler_socket_local::select_write (select_stuff *ss) +{ + select_record *s = ss->start.next; + if (!s->startup) + { + s->startup = start_thread_socket; + s->verify = verify_true; + s->cleanup = socket_cleanup; + } + s->peek = peek_socket; + s->write_ready = saw_shutdown_write () || connect_state () == unconnected; + s->write_selected = true; + if (connect_state () != unconnected) + { + s->except_ready = saw_shutdown_write () || saw_shutdown_read (); + s->except_on_write = true; + } + return s; +} + +select_record * +fhandler_socket_local::select_except (select_stuff *ss) { select_record *s = ss->start.next; if (!s->startup)