summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_socket.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2014-10-26 18:47:24 +0000
committerCorinna Vinschen <corinna@vinschen.de>2014-10-26 18:47:24 +0000
commitb701da7f14e266c6e6182540a104a5b95ee3938f (patch)
treec41449d127001533d383ba8e68654cb5ac21e2bc /winsup/cygwin/fhandler_socket.cc
parent1fc5d69923a27ca6ba128e28befa74734dc53e5e (diff)
downloadcygnal-b701da7f14e266c6e6182540a104a5b95ee3938f.tar.gz
cygnal-b701da7f14e266c6e6182540a104a5b95ee3938f.tar.bz2
cygnal-b701da7f14e266c6e6182540a104a5b95ee3938f.zip
* 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.
Diffstat (limited to 'winsup/cygwin/fhandler_socket.cc')
-rw-r--r--winsup/cygwin/fhandler_socket.cc22
1 files changed, 6 insertions, 16 deletions
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);