ntdll: Don't call try_send before server call in sock_send.

Otherwise, try_send() call from sock_send() may race against try_send()
call from async_send_proc(), shuffling the packet order.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52401
Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jinoh Kang 2022-03-24 02:25:25 +09:00 committed by Alexandre Julliard
parent 0ac256eacc
commit 74059d12b8
2 changed files with 9 additions and 18 deletions

View File

@ -908,21 +908,12 @@ static NTSTATUS sock_send( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, voi
async->iov_cursor = 0;
async->sent_len = 0;
status = try_send( fd, async );
if (status != STATUS_SUCCESS && status != STATUS_DEVICE_NOT_READY)
{
release_fileio( &async->io );
return status;
}
if (status == STATUS_DEVICE_NOT_READY && force_async)
status = STATUS_PENDING;
status = force_async ? STATUS_PENDING : STATUS_DEVICE_NOT_READY;
SERVER_START_REQ( send_socket )
{
req->status = status;
req->total = async->sent_len;
req->total = 0;
req->async = server_async( handle, &async->io, event, apc, apc_user, iosb_client_ptr(io) );
status = wine_server_call( req );
wait_handle = wine_server_ptr_handle( reply->wait );

View File

@ -8010,7 +8010,7 @@ static void test_shutdown(void)
WSASetLastError(0xdeadbeef);
ret = send(client, "test", 5, 0);
ok(ret == -1, "got %d\n", ret);
todo_wine ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
ret = recv(server, buffer, sizeof(buffer), 0);
ok(!ret, "got %d\n", ret);
@ -8057,7 +8057,7 @@ static void test_shutdown(void)
WSASetLastError(0xdeadbeef);
ret = send(server, "test", 5, 0);
ok(ret == -1, "got %d\n", ret);
todo_wine ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
addrlen = sizeof(addr);
ret = getpeername(client, (struct sockaddr *)&addr, &addrlen);
@ -8107,7 +8107,7 @@ static void test_shutdown(void)
WSASetLastError(0xdeadbeef);
ret = send(client, "test", 5, 0);
ok(ret == -1, "got %d\n", ret);
todo_wine ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
ret = recv(server, buffer, sizeof(buffer), 0);
ok(!ret, "got %d\n", ret);
@ -8125,7 +8125,7 @@ static void test_shutdown(void)
WSASetLastError(0xdeadbeef);
ret = send(server, "test", 5, 0);
ok(ret == -1, "got %d\n", ret);
todo_wine ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
addrlen = sizeof(addr);
ret = getpeername(client, (struct sockaddr *)&addr, &addrlen);
@ -8256,7 +8256,7 @@ static void test_shutdown(void)
WSASetLastError(0xdeadbeef);
ret = sendto(client, "test", 5, 0, (struct sockaddr *)&server_addr, sizeof(server_addr));
ok(ret == -1, "got %d\n", ret);
todo_wine ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
closesocket(client);
closesocket(server);
@ -8337,7 +8337,7 @@ static void test_DisconnectEx(void)
WSASetLastError(0xdeadbeef);
ret = send(client, "test", 5, 0);
ok(ret == -1, "expected failure\n");
todo_wine ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
ret = recv(server, buffer, sizeof(buffer), 0);
ok(!ret, "got %d\n", ret);
@ -8391,7 +8391,7 @@ static void test_DisconnectEx(void)
WSASetLastError(0xdeadbeef);
ret = send(client, "test", 5, 0);
ok(ret == -1, "expected failure\n");
todo_wine ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
ret = recv(server, buffer, sizeof(buffer), 0);
ok(!ret, "got %d\n", ret);