Skip to content

Instantly share code, notes, and snippets.

@gofman
Created June 7, 2022 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gofman/cc78a07ed58f6d02ff863388d5992acb to your computer and use it in GitHub Desktop.
Save gofman/cc78a07ed58f6d02ff863388d5992acb to your computer and use it in GitHub Desktop.
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 4a4a3a84e51..296fe948bd0 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -11841,13 +11841,43 @@ static DWORD map_status( NTSTATUS status )
return NT_SUCCESS(status) ? RtlNtStatusToDosErrorNoTeb(status) : WSAEINVAL;
}
+struct WSAGetOverlappedResult_thread_params
+{
+ SOCKET client;
+ HANDLE event;
+};
+
+static DWORD CALLBACK test_WSAGetOverlappedResult_thread(void *arg)
+{
+ struct WSAGetOverlappedResult_thread_params *p = arg;
+ OVERLAPPED overlapped = {0};
+ DWORD size, flags = 0;
+ WSABUF wsa_buf;
+ char data[32];
+ int ret;
+
+ wsa_buf.len = sizeof(data);
+ wsa_buf.buf = data;
+
+ ret = WSARecv(p->client, &wsa_buf, 1, NULL, &flags, &overlapped, NULL);
+ ok(!ret, "got %d.\n", ret);
+ SetEvent(p->event);
+ ret = WSAGetOverlappedResult(p->client, &overlapped, &size, TRUE, &flags);
+ ok(!ret, "got %d.\n", ret);
+ ok(WSAGetLastError() == WSAENOTSOCK, "got %u.\n", WSAGetLastError());
+ trace("thread done, status %#lx.\n", overlapped.Internal);
+ return 0;
+}
+
static void test_WSAGetOverlappedResult(void)
{
+ struct WSAGetOverlappedResult_thread_params params;
OVERLAPPED overlapped = {0};
+ SOCKET s, client, server;
DWORD size, flags;
NTSTATUS status;
unsigned int i;
- SOCKET s;
+ HANDLE thread;
BOOL ret;
static const NTSTATUS ranges[][2] =
@@ -11862,6 +11892,11 @@ static void test_WSAGetOverlappedResult(void)
{0xd0070000, 0xd0080000},
};
+ WSASetLastError(0xdeadbeef);
+ ret = WSAGetOverlappedResult(0xdeadbeef, &overlapped, &size, FALSE, &flags);
+ ok(!ret, "got %d.\n", ret);
+ ok(WSAGetLastError() == WSAENOTSOCK, "got %u.\n", WSAGetLastError());
+
s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
for (i = 0; i < ARRAY_SIZE(ranges); ++i)
@@ -11892,6 +11927,17 @@ static void test_WSAGetOverlappedResult(void)
}
closesocket(s);
+
+ tcp_socketpair(&client, &server);
+
+ params.client = client;
+ params.event = CreateEventW(NULL, FALSE, FALSE, NULL);
+ thread = CreateThread(NULL, 0, test_WSAGetOverlappedResult_thread, &params, 0, NULL);
+ WaitForSingleObject(params.event, INFINITE);
+
+ CloseHandle(params.event);
+ closesocket(client);
+ closesocket(server);
}
struct nonblocking_async_recv_params
@@ -12707,6 +12753,7 @@ START_TEST( sock )
Init();
+if(0){
test_set_getsockopt();
test_so_reuseaddr();
test_ip_pktinfo();
@@ -12766,7 +12813,9 @@ START_TEST( sock )
test_shutdown_completion_port();
test_bind();
test_connecting_socket();
+}
test_WSAGetOverlappedResult();
+return;
test_nonblocking_async_recv();
test_simultaneous_async_recv();
test_empty_recv();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment