Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgor Duda <deo@logos-m.ru>2001-06-20 10:50:13 +0400
committerEgor Duda <deo@logos-m.ru>2001-06-20 10:50:13 +0400
commitae036f47c54449400fb178008094e20e70488711 (patch)
treeb78bd45aabe39755a80515cb34a2768a795a8814 /winsup/cygwin/net.cc
parent4abaaac33c73c2658bc0851f6e0ddc2c39a43a81 (diff)
* fhandler_socket.cc (fhandler_socket::signal_secret_event): New
function. * fhandler.h: Declare it. * fhandler_socket.cc (fhandler_socket::create_secret_event): Don't signal secret event immediately. (fhandler_socket::check_peer_secret_event): Do it after peer event was opened. * net.cc (cygwin_connect): Or if socket is non-blocking. (cygwin_accept): Ditto.
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r--winsup/cygwin/net.cc32
1 files changed, 21 insertions, 11 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 177ae7a2d..bdf679d15 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -739,6 +739,7 @@ cygwin_connect (int fd,
{
int res;
BOOL secret_check_failed = FALSE;
+ BOOL in_progress = FALSE;
fhandler_socket *sock = get (fd);
sockaddr_in sin;
int secret [4];
@@ -759,18 +760,23 @@ cygwin_connect (int fd,
/* Special handling for connect to return the correct error code
when called to early on a non-blocking socket. */
if (WSAGetLastError () == WSAEWOULDBLOCK)
- WSASetLastError (WSAEINPROGRESS);
+ {
+ WSASetLastError (WSAEINPROGRESS);
+ in_progress = TRUE;
+ }
set_winsock_errno ();
}
if (sock->get_addr_family () == AF_UNIX)
{
- if (!res || errno == EINPROGRESS)
+ if (!res || in_progress)
{
if (!sock->create_secret_event (secret))
{
secret_check_failed = TRUE;
}
+ else if (in_progress)
+ sock->signal_secret_event ();
}
if (!secret_check_failed && !res)
@@ -887,6 +893,7 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
{
int res = -1;
BOOL secret_check_failed = FALSE;
+ BOOL in_progress = FALSE;
sigframe thisframe (mainthread);
fhandler_socket *sock = get (fd);
@@ -901,18 +908,21 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
res = accept (sock->get_socket (), peer, len); // can't use a blocking call inside a lock
+ if ((SOCKET) res == (SOCKET) INVALID_SOCKET &&
+ WSAGetLastError () == WSAEWOULDBLOCK)
+ in_progress = TRUE;
+
if (sock->get_addr_family () == AF_UNIX)
{
- if (((SOCKET) res != (SOCKET) INVALID_SOCKET ||
- WSAGetLastError () == WSAEWOULDBLOCK))
- {
- if (!sock->create_secret_event ())
- {
- secret_check_failed = TRUE;
- }
- }
+ if ((SOCKET) res != (SOCKET) INVALID_SOCKET || in_progress)
+ {
+ if (!sock->create_secret_event ())
+ secret_check_failed = TRUE;
+ else if (in_progress)
+ sock->signal_secret_event ();
+ }
- if (!secret_check_failed &&
+ if (!secret_check_failed &&
(SOCKET) res != (SOCKET) INVALID_SOCKET)
{
if (!sock->check_peer_secret_event ((struct sockaddr_in*) peer))