Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- server/sock.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/server/sock.c b/server/sock.c index 0b65a6eb198..5009f6a4f74 100644 --- a/server/sock.c +++ b/server/sock.c @@ -567,7 +567,7 @@ void sock_init(void) } }
-static int sock_reselect( struct sock *sock ) +static void sock_reselect( struct sock *sock ) { int ev = sock_get_poll_events( sock->fd );
@@ -575,7 +575,6 @@ static int sock_reselect( struct sock *sock ) fprintf(stderr,"sock_reselect(%p): new mask %x\n", sock, ev);
set_fd_events( sock->fd, ev ); - return ev; }
static unsigned int afd_poll_flag_to_win32( unsigned int flags )
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ws2_32/tests/afd.c | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
diff --git a/dlls/ws2_32/tests/afd.c b/dlls/ws2_32/tests/afd.c index 3e48b3970ba..96c0eb51226 100644 --- a/dlls/ws2_32/tests/afd.c +++ b/dlls/ws2_32/tests/afd.c @@ -170,11 +170,14 @@ static void test_poll(void) struct afd_poll_params *out_params = (struct afd_poll_params *)out_buffer; int large_buffer_size = 1024 * 1024; SOCKET client, server, listener; + OVERLAPPED overlapped = {0}; struct sockaddr_in addr; + DWORD size, flags = 0; char *large_buffer; IO_STATUS_BLOCK io; LARGE_INTEGER now; ULONG params_size; + WSABUF wsabuf; HANDLE event; int ret, len;
@@ -182,6 +185,7 @@ static void test_poll(void) memset(in_buffer, 0, sizeof(in_buffer)); memset(out_buffer, 0, sizeof(out_buffer)); event = CreateEventW(NULL, TRUE, FALSE, NULL); + overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); ret = bind(listener, (const struct sockaddr *)&bind_addr, sizeof(bind_addr)); @@ -345,6 +349,50 @@ static void test_poll(void) check_poll(client, event, AFD_POLL_WRITE | AFD_POLL_CONNECT | AFD_POLL_READ); check_poll(server, event, AFD_POLL_CONNECT);
+ /* Test sending data while there is a pending WSARecv(). */ + + in_params->timeout = -1000 * 10000; + in_params->count = 1; + in_params->sockets[0].socket = server; + in_params->sockets[0].flags = AFD_POLL_READ; + + ret = NtDeviceIoControlFile((HANDLE)server, event, NULL, NULL, &io, + IOCTL_AFD_POLL, in_params, params_size, out_params, params_size); + ok(ret == STATUS_PENDING, "got %#x\n", ret); + + wsabuf.buf = large_buffer; + wsabuf.len = 1; + ret = WSARecv(server, &wsabuf, 1, NULL, &flags, &overlapped, NULL); + ok(ret == -1, "got %d\n", ret); + ok(WSAGetLastError() == ERROR_IO_PENDING, "got error %u\n", WSAGetLastError()); + + ret = send(client, "a", 1, 0); + ok(ret == 1, "got %d\n", ret); + + ret = WaitForSingleObject(overlapped.hEvent, 200); + ok(!ret, "got %d\n", ret); + ret = GetOverlappedResult((HANDLE)server, &overlapped, &size, FALSE); + ok(ret, "got error %lu\n", GetLastError()); + ok(size == 1, "got size %lu\n", size); + + ret = WaitForSingleObject(event, 0); + todo_wine ok(ret == WAIT_TIMEOUT, "got %#x\n", ret); + + ret = send(client, "a", 1, 0); + ok(ret == 1, "got %d\n", ret); + + ret = WaitForSingleObject(event, 0); + ok(!ret, "got %#x\n", ret); + ok(!io.Status, "got %#lx\n", io.Status); + ok(io.Information == offsetof(struct afd_poll_params, sockets[1]), "got %#Ix\n", io.Information); + ok(out_params->count == 1, "got count %u\n", out_params->count); + ok(out_params->sockets[0].socket == server, "got socket %#Ix\n", out_params->sockets[0].socket); + ok(out_params->sockets[0].flags == AFD_POLL_READ, "got flags %#x\n", out_params->sockets[0].flags); + ok(!out_params->sockets[0].status, "got status %#x\n", out_params->sockets[0].status); + + ret = recv(server, large_buffer, 1, 0); + ok(ret == 1, "got %d\n", ret); + /* Test sending out-of-band data. */
ret = send(client, "a", 1, MSG_OOB); @@ -761,6 +809,7 @@ static void test_poll(void) closesocket(client); closesocket(server);
+ CloseHandle(overlapped.hEvent); CloseHandle(event); free(large_buffer); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=113509
Your paranoid android.
=== w10pro64_ja (64 bit report) ===
ws2_32: afd.c:369: Test failed: got 0x102 afd.c:374: Test failed: got flags 0x44 afd.c:378: Test failed: got -1 afd.c:387: Test failed: got flags 0x43 afd.c:393: Test failed: got flags 0x41
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ws2_32/tests/afd.c | 52 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
diff --git a/dlls/ws2_32/tests/afd.c b/dlls/ws2_32/tests/afd.c index 96c0eb51226..5d72c4660ce 100644 --- a/dlls/ws2_32/tests/afd.c +++ b/dlls/ws2_32/tests/afd.c @@ -169,8 +169,10 @@ static void test_poll(void) struct afd_poll_params *in_params = (struct afd_poll_params *)in_buffer; struct afd_poll_params *out_params = (struct afd_poll_params *)out_buffer; int large_buffer_size = 1024 * 1024; + GUID acceptex_guid = WSAID_ACCEPTEX; SOCKET client, server, listener; OVERLAPPED overlapped = {0}; + LPFN_ACCEPTEX pAcceptEx; struct sockaddr_in addr; DWORD size, flags = 0; char *large_buffer; @@ -196,6 +198,10 @@ static void test_poll(void) ret = getsockname(listener, (struct sockaddr *)&addr, &len); ok(!ret, "got error %u\n", WSAGetLastError());
+ ret = WSAIoctl(listener, SIO_GET_EXTENSION_FUNCTION_POINTER, &acceptex_guid, sizeof(acceptex_guid), + &pAcceptEx, sizeof(pAcceptEx), &size, NULL, NULL); + ok(!ret, "failed to get AcceptEx, error %u\n", WSAGetLastError()); + params_size = offsetof(struct afd_poll_params, sockets[1]); in_params->count = 1;
@@ -689,6 +695,52 @@ static void test_poll(void)
closesocket(client);
+ /* Test connecting while there is a pending AcceptEx(). */ + + in_params->timeout = -1000 * 10000; + in_params->count = 1; + in_params->sockets[0].socket = listener; + in_params->sockets[0].flags = AFD_POLL_ACCEPT; + + ret = NtDeviceIoControlFile((HANDLE)listener, event, NULL, NULL, &io, + IOCTL_AFD_POLL, in_params, params_size, out_params, params_size); + ok(ret == STATUS_PENDING, "got %#x\n", ret); + + server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ret = pAcceptEx(listener, server, large_buffer, 0, 0, sizeof(struct sockaddr_in) + 16, NULL, &overlapped); + ok(!ret, "got %d\n", ret); + ok(WSAGetLastError() == ERROR_IO_PENDING, "got error %u\n", WSAGetLastError()); + + client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ret = connect(client, (struct sockaddr *)&addr, sizeof(addr)); + ok(!ret, "got error %u\n", WSAGetLastError()); + + ret = WaitForSingleObject(overlapped.hEvent, 200); + ok(!ret, "got %d\n", ret); + ret = GetOverlappedResult((HANDLE)listener, &overlapped, &size, FALSE); + ok(ret, "got error %lu\n", GetLastError()); + ok(!size, "got size %lu\n", size); + + ret = WaitForSingleObject(event, 0); + todo_wine ok(ret == WAIT_TIMEOUT, "got %#x\n", ret); + + closesocket(server); + closesocket(client); + + client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ret = connect(client, (struct sockaddr *)&addr, sizeof(addr)); + ok(!ret, "got error %u\n", WSAGetLastError()); + + ret = WaitForSingleObject(event, 0); + ok(!ret, "got %#x\n", ret); + ok(!io.Status, "got %#lx\n", io.Status); + ok(io.Information == offsetof(struct afd_poll_params, sockets[1]), "got %#Ix\n", io.Information); + ok(out_params->count == 1, "got count %u\n", out_params->count); + ok(out_params->sockets[0].socket == listener, "got socket %#Ix\n", out_params->sockets[0].socket); + ok(out_params->sockets[0].flags == AFD_POLL_ACCEPT, "got flags %#x\n", out_params->sockets[0].flags); + ok(!out_params->sockets[0].status, "got status %#x\n", out_params->sockets[0].status); + + closesocket(client); closesocket(listener);
/* Test UDP sockets. */
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=113510
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
ws2_32: afd.c:719: Test failed: got 0x102
=== w7u_adm (32 bit report) ===
ws2_32: afd.c:719: Test failed: got 0x102
=== w8 (32 bit report) ===
ws2_32: afd.c:719: Test failed: got 0x102
=== w8adm (32 bit report) ===
ws2_32: afd.c:719: Test failed: got 0x102
=== w864 (32 bit report) ===
ws2_32: afd.c:719: Test failed: got 0x102
=== w1064v1507 (32 bit report) ===
ws2_32: afd.c:719: Test failed: got 0x102
=== w1064v1809 (32 bit report) ===
ws2_32: afd.c:719: Test failed: got 0x102
=== w1064 (32 bit report) ===
ws2_32: afd.c:719: Test failed: got 0x102
=== w864 (64 bit report) ===
ws2_32: afd.c:719: Test failed: got 0x102
=== w1064v1507 (64 bit report) ===
ws2_32: afd.c:719: Test failed: got 0x102
=== w1064v1809 (64 bit report) ===
ws2_32: afd.c:719: Test failed: got 0x102
=== w1064 (64 bit report) ===
ws2_32: afd.c:719: Test failed: got 0x102
=== w1064_2qxl (64 bit report) ===
ws2_32: afd.c:375: Test failed: got 0x102 afd.c:380: Test failed: got flags 0x44 afd.c:384: Test failed: got -1 afd.c:393: Test failed: got flags 0x43 afd.c:399: Test failed: got flags 0x41
=== w10pro64 (64 bit report) ===
ws2_32: afd.c:719: Test failed: got 0x102
=== w10pro64_ar (64 bit report) ===
ws2_32: afd.c:719: Test failed: got 0x102
=== w10pro64_ja (64 bit report) ===
ws2_32: afd.c:719: Test failed: got 0x102
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ws2_32/tests/sock.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index c3a49d56ed1..a5597e08d10 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -5735,11 +5735,16 @@ static void test_write_events(struct event_test_ctx *ctx)
static void test_read_events(struct event_test_ctx *ctx) { + OVERLAPPED overlapped = {0}; SOCKET server, client; + DWORD size, flags = 0; unsigned int i; char buffer[8]; + WSABUF wsabuf; int ret;
+ overlapped.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL); + tcp_socketpair(&client, &server); set_blocking(client, FALSE);
@@ -5814,8 +5819,36 @@ static void test_read_events(struct event_test_ctx *ctx)
check_events(ctx, 0, 0, 200);
+ /* Send data while there is a pending WSARecv(). */ + + select_events(ctx, server, FD_ACCEPT | FD_CLOSE | FD_CONNECT | FD_OOB | FD_READ); + + wsabuf.buf = buffer; + wsabuf.len = 1; + ret = WSARecv(server, &wsabuf, 1, NULL, &flags, &overlapped, NULL); + ok(ret == -1, "got %d\n", ret); + ok(WSAGetLastError() == ERROR_IO_PENDING, "got error %u\n", WSAGetLastError()); + + ret = send(client, "a", 1, 0); + ok(ret == 1, "got %d\n", ret); + + ret = WaitForSingleObject(overlapped.hEvent, 200); + ok(!ret, "got %d\n", ret); + ret = GetOverlappedResult((HANDLE)server, &overlapped, &size, FALSE); + ok(ret, "got error %lu\n", GetLastError()); + ok(size == 1, "got size %lu\n", size); + + check_events(ctx, 0, 0, 0); + + ret = send(client, "a", 1, 0); + ok(ret == 1, "got %d\n", ret); + + check_events(ctx, FD_READ, 0, 200); + check_events(ctx, 0, 0, 0); + closesocket(server); closesocket(client); + CloseHandle(overlapped.hEvent); }
static void test_oob_events(struct event_test_ctx *ctx)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ws2_32/tests/sock.c | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index a5597e08d10..bfd52e23277 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -5334,12 +5334,23 @@ static void test_accept_events(struct event_test_ctx *ctx) { const struct sockaddr_in addr = {.sin_family = AF_INET, .sin_addr.s_addr = htonl(INADDR_LOOPBACK)}; SOCKET listener, server, client, client2; + GUID acceptex_guid = WSAID_ACCEPTEX; struct sockaddr_in destaddr; + OVERLAPPED overlapped = {0}; + LPFN_ACCEPTEX pAcceptEx; + char buffer[32]; int len, ret; + DWORD size; + + overlapped.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); ok(listener != -1, "failed to create socket, error %u\n", WSAGetLastError());
+ ret = WSAIoctl(listener, SIO_GET_EXTENSION_FUNCTION_POINTER, &acceptex_guid, sizeof(acceptex_guid), + &pAcceptEx, sizeof(pAcceptEx), &size, NULL, NULL); + ok(!ret, "failed to get AcceptEx, error %u\n", WSAGetLastError()); + select_events(ctx, listener, FD_CONNECT | FD_READ | FD_OOB | FD_ACCEPT);
ret = bind(listener, (const struct sockaddr *)&addr, sizeof(addr)); @@ -5537,7 +5548,44 @@ static void test_accept_events(struct event_test_ctx *ctx) closesocket(server); closesocket(client);
+ /* Connect while there is a pending AcceptEx(). */ + + select_events(ctx, listener, FD_CONNECT | FD_READ | FD_OOB | FD_ACCEPT); + + server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ret = pAcceptEx(listener, server, buffer, 0, 0, sizeof(buffer), NULL, &overlapped); + ok(!ret, "got %d\n", ret); + ok(WSAGetLastError() == ERROR_IO_PENDING, "got error %u\n", WSAGetLastError()); + + client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ret = connect(client, (struct sockaddr *)&destaddr, sizeof(destaddr)); + ok(!ret, "got error %u\n", WSAGetLastError()); + + ret = WaitForSingleObject(overlapped.hEvent, 200); + ok(!ret, "got %d\n", ret); + ret = GetOverlappedResult((HANDLE)listener, &overlapped, &size, FALSE); + ok(ret, "got error %lu\n", GetLastError()); + ok(!size, "got size %lu\n", size); + + check_events_todo(ctx, 0, 0, 0); + + closesocket(server); + closesocket(client); + + client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ret = connect(client, (struct sockaddr *)&destaddr, sizeof(destaddr)); + ok(!ret, "got error %u\n", WSAGetLastError()); + + check_events_todo(ctx, FD_ACCEPT, 0, 200); + check_events(ctx, 0, 0, 0); + + server = accept(listener, NULL, NULL); + ok(server != -1, "failed to accept, error %u\n", WSAGetLastError()); + closesocket(server); + closesocket(client); + closesocket(listener); + CloseHandle(overlapped.hEvent); }
static void test_connect_events(struct event_test_ctx *ctx)