Commit 9344a490 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

server: Fail with WSAEINVAL or WSAEALREADY when trying to connect a socket that…

server: Fail with WSAEINVAL or WSAEALREADY when trying to connect a socket that is already connecting via nonblocking connect(). Fixes connection in Mortal Kombat 11; reported by Thomas Crider. Fixes: a891713fSigned-off-by: 's avatarZebediah Figura <z.figura12@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 7326b212
......@@ -2222,7 +2222,8 @@ int WINAPI WS_connect( SOCKET s, const struct WS_sockaddr *addr, int len )
}
if (status)
{
SetLastError( NtStatusToWSAError( status ) );
/* NtStatusToWSAError() has no mapping for WSAEALREADY */
SetLastError( status == STATUS_ADDRESS_ALREADY_ASSOCIATED ? WSAEALREADY : NtStatusToWSAError( status ) );
return -1;
}
return 0;
......
......@@ -10251,7 +10251,7 @@ static void test_connecting_socket(void)
* second to return WSAEALREADY. */
ret = connect(client, (struct sockaddr *)&invalid_addr, sizeof(invalid_addr));
ok(ret == -1, "got %d\n", ret);
todo_wine ok(WSAGetLastError() == WSAEALREADY, "got %u\n", WSAGetLastError());
ok(WSAGetLastError() == WSAEALREADY, "got %u\n", WSAGetLastError());
ret = WSAIoctl(client, SIO_GET_EXTENSION_FUNCTION_POINTER, &connectex_guid, sizeof(connectex_guid),
&pConnectEx, sizeof(pConnectEx), &size, NULL, NULL);
......@@ -10260,7 +10260,7 @@ static void test_connecting_socket(void)
overlapped.InternalHigh = 0xdeadbeef;
ret = pConnectEx(client, (struct sockaddr *)&invalid_addr, sizeof(invalid_addr), NULL, 0, &size, &overlapped);
ok(!ret, "got %d\n", ret);
todo_wine ok(WSAGetLastError() == WSAEINVAL, "got %u\n", WSAGetLastError());
ok(WSAGetLastError() == WSAEINVAL, "got %u\n", WSAGetLastError());
ok((NTSTATUS)overlapped.Internal == STATUS_PENDING, "got status %#x\n", (NTSTATUS)overlapped.Internal);
todo_wine ok(overlapped.InternalHigh == 0xdeadbeef, "got size %Iu\n", overlapped.InternalHigh);
......
......@@ -1784,6 +1784,14 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
return 0;
}
if (sock->state & FD_CONNECT)
{
/* FIXME: STATUS_ADDRESS_ALREADY_ASSOCIATED probably isn't right,
* but there's no status code that maps to WSAEALREADY... */
set_error( params->synchronous ? STATUS_ADDRESS_ALREADY_ASSOCIATED : STATUS_INVALID_PARAMETER );
return 0;
}
ret = connect( unix_fd, addr, params->addr_len );
if (ret < 0 && errno != EINPROGRESS)
{
......
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