From: Zebediah Figura zfigura@codeweavers.com
--- dlls/ws2_32/tests/sock.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 3e6faaffa4c..418721a2541 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -12871,6 +12871,11 @@ static void test_tcp_reset(void) todo_wine ok(ret == -1, "got %d\n", ret); todo_wine ok(WSAGetLastError() == WSAECONNRESET, "got error %u\n", WSAGetLastError());
+ WSASetLastError(0xdeadbeef); + ret = send(client, "data", 5, 0); + ok(ret == -1, "got %d\n", ret); + ok(WSAGetLastError() == WSAECONNRESET, "got error %u\n", WSAGetLastError()); + check_poll(client, POLLERR | POLLHUP | POLLWRNORM);
FD_ZERO(&readfds);
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/ws2_32/tests/sock.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 418721a2541..4651bc09ec6 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -3900,6 +3900,7 @@ static void test_select(void) ret = getsockopt(fdWrite, SOL_SOCKET, SO_ERROR, (char*)&id, &len); ok(!ret, "getsockopt failed with %d\n", WSAGetLastError()); ok(id == 0, "expected 0, got %ld\n", id); + set_blocking(fdRead, FALSE);
/* When data is received the receiver gets the read descriptor */ ret = send(fdWrite, "1234", 4, 0); @@ -3960,6 +3961,11 @@ static void test_select(void) ok(ret == 1, "expected 1, got %d\n", ret); ok(tmp_buf[0] == 'A', "expected 'A', got 0x%02X\n", tmp_buf[0]);
+ /* work around some odd/buggy Linux behaviour */ + ret = recv(fdRead, tmp_buf, sizeof(tmp_buf), 0); + todo_wine ok(ret == -1, "got %d\n", ret); + todo_wine ok(GetLastError() == WSAEWOULDBLOCK, "got error %u\n", WSAGetLastError()); + /* When the connection is closed the socket is set in the read descriptor */ ret = closesocket(fdRead); ok(ret == 0, "expected 0, got %d\n", ret);
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/ws2_32/tests/sock.c | 20 ++++++++++---------- server/sock.c | 5 ++++- 2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 4651bc09ec6..dfed16d40b4 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -9830,9 +9830,9 @@ static void test_completion_port(void)
/* Somehow a hard shutdown doesn't work on my Linux box. It seems SO_LINGER is ignored. */ iret = WSARecv(dest, &bufs, 1, &num_bytes, &flags, &ov, NULL); - todo_wine ok(iret == SOCKET_ERROR, "WSARecv failed - %d\n", iret); - todo_wine ok(GetLastError() == WSAECONNRESET, "Last error was %ld\n", GetLastError()); - todo_wine ok(num_bytes == 0xdeadbeef, "Managed to read %ld\n", num_bytes); + ok(iret == SOCKET_ERROR, "WSARecv failed - %d\n", iret); + ok(GetLastError() == WSAECONNRESET, "Last error was %ld\n", GetLastError()); + ok(num_bytes == 0xdeadbeef, "Managed to read %ld\n", num_bytes);
SetLastError(0xdeadbeef); key = 0xdeadbeef; @@ -9840,11 +9840,11 @@ static void test_completion_port(void) olp = (WSAOVERLAPPED *)0xdeadbeef;
bret = GetQueuedCompletionStatus( io_port, &num_bytes, &key, &olp, 200 ); - todo_wine ok(bret == FALSE, "GetQueuedCompletionStatus returned %u\n", bret ); - todo_wine ok(GetLastError() == WAIT_TIMEOUT, "Last error was %ld\n", GetLastError()); - todo_wine ok(key == 0xdeadbeef, "Key is %Iu\n", key); - todo_wine ok(num_bytes == 0xdeadbeef, "Number of bytes transferred is %lu\n", num_bytes); - todo_wine ok(!olp, "Overlapped structure is at %p\n", olp); + ok(bret == FALSE, "GetQueuedCompletionStatus returned %u\n", bret ); + ok(GetLastError() == WAIT_TIMEOUT, "Last error was %ld\n", GetLastError()); + ok(key == 0xdeadbeef, "Key is %Iu\n", key); + ok(num_bytes == 0xdeadbeef, "Number of bytes transferred is %lu\n", num_bytes); + ok(!olp, "Overlapped structure is at %p\n", olp);
closesocket(dest);
@@ -12874,8 +12874,8 @@ static void test_tcp_reset(void) WSASetLastError(0xdeadbeef); size = 0xdeadbeef; ret = WSARecv(client, &wsabuf, 1, &size, &flags, &overlapped, NULL); - todo_wine ok(ret == -1, "got %d\n", ret); - todo_wine ok(WSAGetLastError() == WSAECONNRESET, "got error %u\n", WSAGetLastError()); + ok(ret == -1, "got %d\n", ret); + ok(WSAGetLastError() == WSAECONNRESET, "got error %u\n", WSAGetLastError());
WSASetLastError(0xdeadbeef); ret = send(client, "data", 5, 0); diff --git a/server/sock.c b/server/sock.c index 7d7e470be28..49ce4d254f6 100644 --- a/server/sock.c +++ b/server/sock.c @@ -3461,7 +3461,10 @@ DECL_HANDLER(recv_socket) if (!req->force_async && !sock->nonblocking && is_fd_overlapped( fd )) timeout = (timeout_t)sock->rcvtimeo * -10000;
- if (sock->rd_shutdown) status = STATUS_PIPE_DISCONNECTED; + if (sock->rd_shutdown) + status = STATUS_PIPE_DISCONNECTED; + else if (sock->reset) + status = STATUS_CONNECTION_RESET; else if (!async_queued( &sock->read_q )) { /* If read_q is not empty, we cannot really tell if the already queued
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/ws2_32/tests/sock.c | 2 +- server/sock.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index dfed16d40b4..8f7874db713 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -6446,7 +6446,7 @@ static void test_close_events(struct event_test_ctx *ctx)
close_with_rst(client);
- check_events_todo_msg(ctx, MAKELONG(FD_CLOSE, WSAECONNABORTED), 0, 200); + check_events(ctx, MAKELONG(FD_CLOSE, WSAECONNABORTED), 0, 200); check_events(ctx, 0, 0, 0); select_events(ctx, server, FD_ACCEPT | FD_CLOSE | FD_CONNECT | FD_OOB | FD_READ); if (ctx->is_message) diff --git a/server/sock.c b/server/sock.c index 49ce4d254f6..072aac67723 100644 --- a/server/sock.c +++ b/server/sock.c @@ -631,7 +631,11 @@ static void sock_wake_up( struct sock *sock ) enum afd_poll_bit event = event_bitorder[i]; if (events & (1 << event)) { - lparam_t lparam = afd_poll_flag_to_win32(1 << event) | (sock_get_error( sock->errors[event] ) << 16); + lparam_t lparam; + if (event == AFD_POLL_BIT_RESET) + lparam = FD_CLOSE | (WSAECONNABORTED << 16); + else + lparam = afd_poll_flag_to_win32(1 << event) | (sock_get_error( sock->errors[event] ) << 16); post_message( sock->window, sock->message, sock->wparam, lparam ); } }
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/ws2_32/socket.c | 5 ++++- dlls/ws2_32/tests/sock.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 9d51fef1adb..3171f0cd5ca 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -3584,7 +3584,10 @@ int WINAPI WSAEnumNetworkEvents( SOCKET s, WSAEVENT event, WSANETWORKEVENTS *ret if (ret_events->lNetworkEvents & FD_CLOSE) { if (!(ret_events->iErrorCode[FD_CLOSE_BIT] = NtStatusToWSAError( params.status[AFD_POLL_BIT_HUP] ))) - ret_events->iErrorCode[FD_CLOSE_BIT] = NtStatusToWSAError( params.status[AFD_POLL_BIT_RESET] ); + { + if (params.flags & AFD_POLL_RESET) + ret_events->iErrorCode[FD_CLOSE_BIT] = WSAECONNABORTED; + } } } SetLastError( NtStatusToWSAError( status ) ); diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 8f7874db713..05a6539b5c6 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -5602,7 +5602,7 @@ static void check_events_(int line, struct event_test_ctx *ctx, for (i = 0; i < ARRAY_SIZE(events.iErrorCode); ++i) { if ((1u << i) == LOWORD(flag1) && (events.lNetworkEvents & LOWORD(flag1))) - todo_wine_if (HIWORD(flag1)) ok_(__FILE__, line)(events.iErrorCode[i] == HIWORD(flag1), + ok_(__FILE__, line)(events.iErrorCode[i] == HIWORD(flag1), "got error code %d for event %#x\n", events.iErrorCode[i], 1u << i); if ((1u << i) == LOWORD(flag2) && (events.lNetworkEvents & LOWORD(flag2))) ok_(__FILE__, line)(events.iErrorCode[i] == HIWORD(flag2),
This is breaking tests: ``` tools/runtest -q -P wine -T . -M httpapi.dll -p dlls/httpapi/tests/httpapi_test.exe httpapi && touch dlls/httpapi/tests/httpapi.ok httpapi.c:940: Test failed: Connection should be shut down. httpapi.c:941: Test failed: Got error 10054. make: *** [Makefile:56268: dlls/httpapi/tests/httpapi.ok] Error 2 ```