diff options
-rw-r--r-- | winsup/cygwin/ChangeLog | 10 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.h | 9 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_socket.cc | 22 | ||||
-rw-r--r-- | winsup/cygwin/release/1.7.33 | 3 |
4 files changed, 21 insertions, 23 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 79ce16c70..79f32e7ca 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2014-10-26 Corinna Vinschen <corinna@vinschen.de> + + * fhandler_socket.cc (fhandler_socket::af_local_connect): Drop + setting connect_state to connect_credxchg. + (fhandler_socket::af_local_accept): Ditto. + (fhandler_socket::recv_internal): Drop ill-advised connect_state check. + Add comment so as not to repeat the exercise. + * fhandler.h (enum conn_state): Drop now unneeded connect_credxchg + state. + 2014-10-24 Corinna Vinschen <corinna@vinschen.de> * fhandler_proc.cc (format_proc_cygdrive): Fix symlink path if cygdrive diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index aff8d85e0..54c81dce6 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -75,11 +75,10 @@ enum dirent_states enum conn_state { unconnected = 0, - connect_credxchg = 1, - connect_pending = 2, - connected = 3, - listener = 4, - connect_failed = 5 + connect_pending = 1, + connected = 2, + listener = 3, + connect_failed = 4 }; enum line_edit_status diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 6a13e4d77..59561bc58 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -405,7 +405,6 @@ fhandler_socket::af_local_connect () if (no_getpeereid ()) return 0; - connect_state (connect_credxchg); af_local_setblocking (orig_async_io, orig_is_nonblocking); if (!af_local_send_secret () || !af_local_recv_secret () || !af_local_send_cred () || !af_local_recv_cred ()) @@ -428,7 +427,6 @@ fhandler_socket::af_local_accept () if (no_getpeereid ()) return 0; - connect_state (connect_credxchg); af_local_setblocking (orig_async_io, orig_is_nonblocking); if (!af_local_recv_secret () || !af_local_send_secret () || !af_local_recv_cred () || !af_local_send_cred ()) @@ -1465,20 +1463,12 @@ fhandler_socket::recv_internal (LPWSAMSG wsamsg, bool use_recvmsg) static NO_COPY LPFN_WSARECVMSG WSARecvMsg; int orig_namelen = wsamsg->namelen; - /* Windows event handling does not check for the validity of the desired - flags so we have to do it here. - The check goes like this: - STREAM sockets must be either connected, or they are AF_LOCAL - sockets in the pre-connected credential exchange phase. - All other states are disallowed. */ - if (get_socket_type () == SOCK_STREAM && connect_state () != connected - && (get_addr_family () != AF_LOCAL - || connect_state () != connect_credxchg)) - { - WSASetLastError (WSAENOTCONN); - set_winsock_errno (); - return SOCKET_ERROR; - } + /* CV 2014-10-26: Do not check for the connect_state at this point. In + certain scenarios there's no way to check the connect state reliably. + Example (hexchat): Parent process creates socket, forks, child process + calls connect, parent process calls read. Even if the event handling + allows to check for FD_CONNECT in the parent, there is always yet another + scenario we can easily break. */ DWORD wait_flags = wsamsg->dwFlags; bool waitall = !!(wait_flags & MSG_WAITALL); diff --git a/winsup/cygwin/release/1.7.33 b/winsup/cygwin/release/1.7.33 index 1be06022d..864d99ba8 100644 --- a/winsup/cygwin/release/1.7.33 +++ b/winsup/cygwin/release/1.7.33 @@ -68,8 +68,7 @@ Bug Fixes Addresses: https://cygwin.com/ml/cygwin-developers/2014-10/msg00010.html - Don't hang in accept calls if socket is no listener. Set errno to EINVAL - instead. Don't hang in read/recv/recvfrom/recvmsg calls if socket is - connection oriented and not connected. Set errno to ENOTCONN instead. + instead. - Don't allow seeking on serial lines and sockets. Set errno to ESPIPE instead. |