summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_socket.cc
diff options
context:
space:
mode:
authorThomas Pfaff <tpfaff@gmx.net>2003-06-07 11:05:35 +0000
committerThomas Pfaff <tpfaff@gmx.net>2003-06-07 11:05:35 +0000
commitf496071c4072d8c3db27ce51a0a3e13729b7be4c (patch)
tree30500efeff3f572aa791938475b3c3dac8c7dd2c /winsup/cygwin/fhandler_socket.cc
parent729d1ff9d89641b443bca6fcd5d4a9e3d9f3896a (diff)
downloadcygnal-f496071c4072d8c3db27ce51a0a3e13729b7be4c.tar.gz
cygnal-f496071c4072d8c3db27ce51a0a3e13729b7be4c.tar.bz2
cygnal-f496071c4072d8c3db27ce51a0a3e13729b7be4c.zip
* fhandler_socket.cc (fhandler_socket::connect): Change error
handling for nonblocking connects to return EALREADY when connect is called more than once for the same socket.
Diffstat (limited to 'winsup/cygwin/fhandler_socket.cc')
-rw-r--r--winsup/cygwin/fhandler_socket.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 894e980e6..3dd8d6762 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -502,6 +502,7 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen)
BOOL in_progress = FALSE;
sockaddr_in sin;
int secret [4];
+ DWORD err;
if (!get_inet_addr (name, namelen, &sin, &namelen, secret))
return -1;
@@ -514,12 +515,12 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen)
when called on a non-blocking socket. */
if (is_nonblocking () || is_connect_pending ())
{
- DWORD err = WSAGetLastError ();
+ err = WSAGetLastError ();
if (err == WSAEWOULDBLOCK || err == WSAEALREADY)
- {
- WSASetLastError (WSAEINPROGRESS);
- in_progress = TRUE;
- }
+ in_progress = TRUE;
+
+ if (err == WSAEWOULDBLOCK)
+ WSASetLastError (WSAEINPROGRESS);
else if (err == WSAEINVAL)
WSASetLastError (WSAEISCONN);
}
@@ -556,7 +557,8 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen)
}
}
- if (WSAGetLastError () == WSAEINPROGRESS)
+ err = WSAGetLastError ();
+ if (err == WSAEINPROGRESS || err == WSAEALREADY)
set_connect_state (CONNECT_PENDING);
else
set_connect_state (CONNECTED);