diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2006-07-27 17:58:54 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2006-07-27 17:58:54 +0400 |
commit | fd5879c110763e58717a23b259ecabd01a88684b (patch) | |
tree | 06d1bbfc98d6e9ad63bb65a2def2fdb687f47b15 /winsup/cygwin/fhandler_socket.cc | |
parent | 883861544a879eb161b1186ba6c62335a923aaca (diff) |
* fhandler_socket.cc: Revert misguided attempt to handle FD_CLOSE error
conditions in evaluate_events.
(search_wsa_event_slot): Move wrongly placed memset in
fhandler_socket::init_events here.
(fhandler_socket::init_events): Initially set FD_WRITE event for
connectionless sockets.
* poll.cc (poll): Don't add sockets always to except_fds since select
is now supposed to do it right.
* select.cc (set_bits): Set connection state correctly for failed
af_local_connect on local sockets. Remove socket special handling
for except_selected descriptors.
(peek_socket): Try to set the read/write/exception bits actually
correctly.
Diffstat (limited to 'winsup/cygwin/fhandler_socket.cc')
-rw-r--r-- | winsup/cygwin/fhandler_socket.cc | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 760dbc456..4a5177a02 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -386,7 +386,7 @@ struct wsa_event { LONG serial_number; long events; - int errorcode; + int connect_errorcode; pid_t owner; }; @@ -443,6 +443,7 @@ search_wsa_event_slot (LONG new_serial_number) return NULL; } } + memset (&wsa_events[slot], 0, sizeof (wsa_event)); wsa_events[slot].serial_number = new_serial_number; ReleaseMutex (wsa_slot_mtx); return wsa_events + slot; @@ -490,7 +491,9 @@ fhandler_socket::init_events () return false; } wsock_events = search_wsa_event_slot (new_serial_number); - memset (wsock_events, 0, sizeof *wsock_events); + /* sock type not yet set here. */ + if (pc.dev == FH_UDP || pc.dev == FH_DGRAM) + wsock_events->events = FD_WRITE; return true; } @@ -508,9 +511,7 @@ fhandler_socket::evaluate_events (const long event_mask, long &events, LOCK_EVENTS; wsock_events->events |= evts.lNetworkEvents; if (evts.lNetworkEvents & FD_CONNECT) - wsock_events->errorcode = evts.iErrorCode[FD_CONNECT_BIT]; - else if (evts.lNetworkEvents & FD_CLOSE) - wsock_events->errorcode = evts.iErrorCode[FD_CLOSE_BIT]; + wsock_events->connect_errorcode = evts.iErrorCode[FD_CONNECT_BIT]; UNLOCK_EVENTS; if ((evts.lNetworkEvents & FD_OOB) && wsock_events->owner) kill (wsock_events->owner, SIGURG); @@ -520,22 +521,18 @@ fhandler_socket::evaluate_events (const long event_mask, long &events, LOCK_EVENTS; if ((events = (wsock_events->events & event_mask)) != 0) { - if (events & (FD_CONNECT | FD_CLOSE)) + if (events & FD_CONNECT) { int wsa_err = 0; - if ((wsa_err = wsock_events->errorcode) != 0) + if ((wsa_err = wsock_events->connect_errorcode) != 0) { WSASetLastError (wsa_err); ret = SOCKET_ERROR; } - if (events & FD_CONNECT) - { - if (!wsock_events->errorcode) - wsock_events->events |= FD_WRITE; - wsock_events->events &= ~FD_CONNECT; - } - if (!(events & FD_CLOSE)) - wsock_events->errorcode = 0; + else + wsock_events->events |= FD_WRITE; + wsock_events->events &= ~FD_CONNECT; + wsock_events->connect_errorcode = 0; } if (erase) wsock_events->events &= ~(events & ~(FD_WRITE | FD_CLOSE)); |