Huw Davies : ws2_32: Don' t return synchronously if the connection is refused.
Alexandre Julliard
julliard at winehq.org
Sat Aug 12 07:19:32 CDT 2017
Module: wine
Branch: master
Commit: 2910dcea8997e51900055e44544ea7cfa5ad9c34
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2910dcea8997e51900055e44544ea7cfa5ad9c34
Author: Huw Davies <huw at codeweavers.com>
Date: Tue Aug 8 08:34:30 2017 +0100
ws2_32: Don't return synchronously if the connection is refused.
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ws2_32/socket.c | 8 +++++++-
dlls/ws2_32/tests/sock.c | 20 ++++++--------------
2 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 9cae18f..06f1c26 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -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) );
}
}
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 43008cf..897839a 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -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)
More information about the wine-cvs
mailing list