Commit 2910dcea authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

ws2_32: Don't return synchronously if the connection is refused.

parent 448ac0e9
......@@ -3586,7 +3586,13 @@ static BOOL WINAPI WS2_ConnectEx(SOCKET s, const struct WS_sockaddr* name, int n
/* If the connect already failed */
if (status == STATUS_PIPE_DISCONNECTED)
status = _get_sock_error(s, FD_CONNECT_BIT);
{
ov->Internal = _get_sock_error(s, FD_CONNECT_BIT);
ov->InternalHigh = 0;
if (cvalue) WS_AddCompletion( s, cvalue, ov->Internal, ov->InternalHigh );
if (ov->hEvent) NtSetEvent( ov->hEvent, NULL );
status = STATUS_PENDING;
}
SetLastError( NtStatusToWSAError(status) );
}
}
......
......@@ -7915,22 +7915,14 @@ static void test_ConnectEx(void)
address.sin_port = htons(1);
bret = pConnectEx(connector, (struct sockaddr*)&address, addrlen, NULL, 0, &bytesReturned, &overlapped);
ok(bret == FALSE && GetLastError(), "ConnectEx to bad destination failed: "
ok(bret == FALSE && GetLastError() == ERROR_IO_PENDING, "ConnectEx to bad destination failed: "
"returned %d + errno %d\n", bret, GetLastError());
dwret = WaitForSingleObject(overlapped.hEvent, 15000);
ok(dwret == WAIT_OBJECT_0, "Waiting for connect event failed with %d + errno %d\n", dwret, GetLastError());
if (GetLastError() == ERROR_IO_PENDING)
{
dwret = WaitForSingleObject(overlapped.hEvent, 15000);
ok(dwret == WAIT_OBJECT_0, "Waiting for connect event failed with %d + errno %d\n", dwret, GetLastError());
bret = GetOverlappedResult((HANDLE)connector, &overlapped, &bytesReturned, FALSE);
ok(bret == FALSE && GetLastError() == ERROR_CONNECTION_REFUSED,
"Connecting to a disconnected host returned error %d - %d\n", bret, WSAGetLastError());
}
else {
ok(GetLastError() == WSAECONNREFUSED,
"Connecting to a disconnected host returned error %d - %d\n", bret, WSAGetLastError());
}
bret = GetOverlappedResult((HANDLE)connector, &overlapped, &bytesReturned, FALSE);
ok(bret == FALSE && GetLastError() == ERROR_CONNECTION_REFUSED,
"Connecting to a disconnected host returned error %d - %d\n", bret, WSAGetLastError());
end:
if (overlapped.hEvent)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment