ntdll: Don't call try_recv before server call in sock_recv.

Otherwise, try_recv() call from sock_recv() may race against try_recv()
call from async_recv_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-02-10 01:18:05 +09:00 committed by Alexandre Julliard
parent e5ce4fa917
commit 160eb74fdf
2 changed files with 6 additions and 14 deletions

View File

@ -737,16 +737,8 @@ static NTSTATUS sock_recv( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, voi
}
}
status = try_recv( fd, async, &information );
if (status != STATUS_SUCCESS && status != STATUS_BUFFER_OVERFLOW && 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;
information = 0;
SERVER_START_REQ( recv_socket )
{

View File

@ -7813,8 +7813,8 @@ static void test_shutdown(void)
WSASetLastError(0xdeadbeef);
ret = recv(server, buffer, sizeof(buffer), 0);
todo_wine ok(ret == -1, "got %d\n", ret);
todo_wine ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
ok(ret == -1, "got %d\n", ret);
ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
ret = send(server, "test", 5, 0);
ok(ret == 5, "got %d\n", ret);
@ -7908,8 +7908,8 @@ static void test_shutdown(void)
WSASetLastError(0xdeadbeef);
ret = recv(server, buffer, sizeof(buffer), 0);
todo_wine ok(ret == -1, "got %d\n", ret);
todo_wine ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
ok(ret == -1, "got %d\n", ret);
ok(WSAGetLastError() == WSAESHUTDOWN, "got error %u\n", WSAGetLastError());
WSASetLastError(0xdeadbeef);
ret = send(server, "test", 5, 0);