Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ws2_32/tests/sock.c | 21 ++++++++++----------- server/sock.c | 3 ++- 2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index ec78e62969e..7611b934c3a 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -2641,9 +2641,8 @@ static void test_WSAEnumNetworkEvents(void) } else { - todo_wine_if (i != 0) /* Remove when fixed */ - ok (net_events.lNetworkEvents == 0, "Test[%d]: expected 0, got %d\n", - i, net_events.lNetworkEvents); + ok (net_events.lNetworkEvents == 0, "Test[%d]: expected 0, got %d\n", + i, net_events.lNetworkEvents); } for (k = 0; k < FD_MAX_EVENTS; k++) { @@ -3990,12 +3989,12 @@ static void test_accept_events(struct event_test_ctx *ctx) select_events(ctx, listener, FD_CONNECT | FD_READ | FD_OOB | FD_ACCEPT); if (ctx->is_message) check_events(ctx, FD_ACCEPT, 0, 200); - check_events_todo_event(ctx, 0, 0, 0); + check_events(ctx, 0, 0, 0); select_events(ctx, listener, 0); select_events(ctx, listener, FD_CONNECT | FD_READ | FD_OOB | FD_ACCEPT); if (ctx->is_message) check_events(ctx, FD_ACCEPT, 0, 200); - check_events_todo_event(ctx, 0, 0, 0); + check_events(ctx, 0, 0, 0);
client2 = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); ok(client2 != -1, "failed to create socket, error %u\n", WSAGetLastError()); @@ -4134,7 +4133,7 @@ static void test_connect_events(struct event_test_ctx *ctx) select_events(ctx, client, FD_ACCEPT | FD_CLOSE | FD_CONNECT | FD_OOB | FD_READ | FD_WRITE); if (ctx->is_message) check_events(ctx, FD_WRITE, 0, 200); - check_events_todo_event(ctx, 0, 0, 0); + check_events(ctx, 0, 0, 0);
server = accept(listener, NULL, NULL); ok(server != -1, "failed to accept, error %u\n", WSAGetLastError()); @@ -4235,12 +4234,12 @@ static void test_write_events(struct event_test_ctx *ctx) select_events(ctx, server, FD_ACCEPT | FD_CLOSE | FD_CONNECT | FD_OOB | FD_READ | FD_WRITE); if (ctx->is_message) check_events(ctx, FD_WRITE, 0, 200); - check_events_todo_event(ctx, 0, 0, 0); + check_events(ctx, 0, 0, 0); select_events(ctx, server, 0); select_events(ctx, server, FD_ACCEPT | FD_CLOSE | FD_CONNECT | FD_OOB | FD_READ | FD_WRITE); if (ctx->is_message) check_events(ctx, FD_WRITE, 0, 200); - check_events_todo_event(ctx, 0, 0, 0); + check_events(ctx, 0, 0, 0);
ret = send(server, "data", 5, 0); ok(ret == 5, "got %d\n", ret); @@ -4268,7 +4267,7 @@ static void test_write_events(struct event_test_ctx *ctx) select_events(ctx, server, FD_ACCEPT | FD_CLOSE | FD_CONNECT | FD_OOB | FD_READ | FD_WRITE); if (ctx->is_message) check_events(ctx, FD_WRITE, 0, 200); - check_events_todo_event(ctx, 0, 0, 0); + check_events(ctx, 0, 0, 0); }
closesocket(server); @@ -4313,12 +4312,12 @@ static void test_read_events(struct event_test_ctx *ctx) select_events(ctx, server, FD_ACCEPT | FD_CLOSE | FD_CONNECT | FD_OOB | FD_READ); if (ctx->is_message) check_events(ctx, FD_READ, 0, 200); - check_events_todo_event(ctx, 0, 0, 0); + check_events(ctx, 0, 0, 0); select_events(ctx, server, 0); select_events(ctx, server, FD_ACCEPT | FD_CLOSE | FD_CONNECT | FD_OOB | FD_READ); if (ctx->is_message) check_events(ctx, FD_READ, 0, 200); - check_events_todo_event(ctx, 0, 0, 0); + check_events(ctx, 0, 0, 0);
ret = send(client, "data", 5, 0); ok(ret == 5, "got %d\n", ret); diff --git a/server/sock.c b/server/sock.c index bd65cfc68c3..ad80b897365 100644 --- a/server/sock.c +++ b/server/sock.c @@ -1780,7 +1780,8 @@ DECL_HANDLER(set_socket_event) if (get_unix_fd( sock->fd ) == -1) return; old_event = sock->event; sock->mask = req->mask; - sock->reported_events &= ~req->mask; /* re-enable held events */ + if (req->window) + sock->reported_events &= ~req->mask; /* re-enable held events */ sock->event = NULL; sock->window = req->window; sock->message = req->msg;
Signed-off-by: Zebediah Figura z.figura12@gmail.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 7611b934c3a..2d9c0958dd7 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -4463,6 +4463,11 @@ static void test_close_events(struct event_test_ctx *ctx) check_events_todo_msg(ctx, FD_CLOSE, 0, 200); check_events(ctx, 0, 0, 0);
+ ret = recv(server, buffer, 5, 0); + ok(!ret, "got %d\n", ret); + + check_events(ctx, 0, 0, 0); + closesocket(server);
/* Test shutdown(remote end, SD_SEND). */
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ws2_32/tests/sock.c | 2 +- server/sock.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 2d9c0958dd7..1732c9bf3ee 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -4177,7 +4177,7 @@ static void test_connect_events(struct event_test_ctx *ctx) server = accept(listener, NULL, NULL); ok(server != -1, "failed to accept, error %u\n", WSAGetLastError());
- check_events_todo_msg(ctx, FD_WRITE, 0, 200); + check_events(ctx, FD_WRITE, 0, 200);
select_events(ctx, client, FD_ACCEPT | FD_CLOSE | FD_CONNECT | FD_OOB | FD_READ | FD_WRITE);
diff --git a/server/sock.c b/server/sock.c index ad80b897365..f74c9396f26 100644 --- a/server/sock.c +++ b/server/sock.c @@ -413,7 +413,7 @@ static void sock_wake_up( struct sock *sock ) for (i = 0; i < FD_MAX_EVENTS; i++) { int event = event_bitorder[i]; - if (sock->pending_events & (1 << event)) + if (events & (1 << event)) { lparam_t lparam = (1 << event) | (sock->errors[event] << 16); post_message( sock->window, sock->message, sock->wparam, lparam );
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- This adds a test failure. However, this failure reflects an improvement in Wine, as we no longer incorrectly report that the following recv() call will succeed.
Moreover, it prevents a test failure that would otherwise be introduced with the following patch.
dlls/ws2_32/socket.c | 12 ++++++------ dlls/ws2_32/tests/sock.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 3a8bfa0ce41..0a23b44cc68 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -2110,14 +2110,14 @@ static NTSTATUS WS2_async_recv( void *user, IO_STATUS_BLOCK *iosb, NTSTATUS stat if (result >= 0) { status = STATUS_SUCCESS; - _enable_event( wsa->hSocket, FD_READ, 0, 0 ); + _enable_event( wsa->hSocket, (wsa->flags & WS_MSG_OOB) ? FD_OOB : FD_READ, 0, 0 ); } else { if (errno == EAGAIN) { status = STATUS_PENDING; - _enable_event( wsa->hSocket, FD_READ, 0, 0 ); + _enable_event( wsa->hSocket, (wsa->flags & WS_MSG_OOB) ? FD_OOB : FD_READ, 0, 0 ); } else { @@ -6180,7 +6180,7 @@ static int WS2_recv_base( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, } else NtQueueApcThread( GetCurrentThread(), (PNTAPCFUNC)ws2_async_apc, (ULONG_PTR)wsa, (ULONG_PTR)iosb, 0 ); - _enable_event(SOCKET2HANDLE(s), FD_READ, 0, 0); + _enable_event(SOCKET2HANDLE(s), (wsa->flags & WS_MSG_OOB) ? FD_OOB : FD_READ, 0, 0); return 0; }
@@ -6209,13 +6209,13 @@ static int WS2_recv_base( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, { err = WSAETIMEDOUT; /* a timeout is not fatal */ - _enable_event(SOCKET2HANDLE(s), FD_READ, 0, 0); + _enable_event(SOCKET2HANDLE(s), (wsa->flags & WS_MSG_OOB) ? FD_OOB : FD_READ, 0, 0); goto error; } } else { - _enable_event(SOCKET2HANDLE(s), FD_READ, 0, 0); + _enable_event(SOCKET2HANDLE(s), (wsa->flags & WS_MSG_OOB) ? FD_OOB : FD_READ, 0, 0); err = WSAEWOULDBLOCK; goto error; } @@ -6224,7 +6224,7 @@ static int WS2_recv_base( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, TRACE(" -> %i bytes\n", n); if (wsa != &localwsa) HeapFree( GetProcessHeap(), 0, wsa ); release_sock_fd( s, fd ); - _enable_event(SOCKET2HANDLE(s), FD_READ, 0, 0); + _enable_event(SOCKET2HANDLE(s), (wsa->flags & WS_MSG_OOB) ? FD_OOB : FD_READ, 0, 0); SetLastError(ERROR_SUCCESS);
return 0; diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 1732c9bf3ee..596e1ec1a21 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -4413,7 +4413,7 @@ static void test_oob_events(struct event_test_ctx *ctx) ret = recv(server, buffer, 1, MSG_OOB); ok(ret == 1, "got %d\n", ret);
- check_events_todo_msg(ctx, FD_OOB, 0, 200); + check_events_todo(ctx, FD_OOB, 0, 200); check_events_todo_msg(ctx, 0, 0, 0);
ret = recv(server, buffer, 1, MSG_OOB);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- This introduces a test failure, reflecting a failure to trigger FD_OOB after two separate bytes of OOB data are sent. Since two bytes are not actually received, and since the first is never consumed anyway, I am again inclined to argue that this makes the test results more accurate rather than less.
dlls/ws2_32/tests/sock.c | 22 +++++++++++----------- server/sock.c | 9 ++++++--- 2 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 596e1ec1a21..266ddc14451 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -4391,35 +4391,35 @@ static void test_oob_events(struct event_test_ctx *ctx) ret = send(client, "a", 1, MSG_OOB); ok(ret == 1, "got %d\n", ret);
- check_events_todo_msg(ctx, FD_OOB, 0, 200); - check_events_todo(ctx, 0, 0, 0); + check_events(ctx, FD_OOB, 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) - check_events_todo_msg(ctx, FD_OOB, 0, 200); - check_events_todo(ctx, 0, 0, 0); + check_events(ctx, FD_OOB, 0, 200); + check_events(ctx, 0, 0, 0); select_events(ctx, server, 0); select_events(ctx, server, FD_ACCEPT | FD_CLOSE | FD_CONNECT | FD_OOB | FD_READ); if (ctx->is_message) - check_events_todo_msg(ctx, FD_OOB, 0, 200); - check_events_todo(ctx, 0, 0, 0); + check_events(ctx, FD_OOB, 0, 200); + check_events(ctx, 0, 0, 0);
ret = send(client, "b", 1, MSG_OOB); ok(ret == 1, "got %d\n", ret);
if (!ctx->is_message) - check_events(ctx, FD_OOB, 0, 200); - check_events_todo(ctx, 0, 0, 0); + check_events_todo_event(ctx, FD_OOB, 0, 200); + check_events(ctx, 0, 0, 0);
ret = recv(server, buffer, 1, MSG_OOB); ok(ret == 1, "got %d\n", ret);
check_events_todo(ctx, FD_OOB, 0, 200); - check_events_todo_msg(ctx, 0, 0, 0); + check_events(ctx, 0, 0, 0);
ret = recv(server, buffer, 1, MSG_OOB); todo_wine ok(ret == 1, "got %d\n", ret);
- check_events_todo_msg(ctx, 0, 0, 0); + check_events(ctx, 0, 0, 0);
/* Send data while we're not selecting. */
@@ -4428,7 +4428,7 @@ static void test_oob_events(struct event_test_ctx *ctx) ok(ret == 1, "got %d\n", ret); select_events(ctx, server, FD_ACCEPT | FD_CLOSE | FD_CONNECT | FD_OOB | FD_READ);
- check_events_todo_msg(ctx, FD_OOB, 0, 200); + check_events(ctx, FD_OOB, 0, 200);
ret = recv(server, buffer, 1, MSG_OOB); ok(ret == 1, "got %d\n", ret); diff --git a/server/sock.c b/server/sock.c index f74c9396f26..c8cd603149b 100644 --- a/server/sock.c +++ b/server/sock.c @@ -627,9 +627,12 @@ static void post_socket_event( struct sock *sock, unsigned int event_bit, unsign { unsigned int event = (1 << event_bit);
- sock->pending_events |= event; - sock->reported_events |= event; - sock->errors[event_bit] = error; + if (!(sock->reported_events & event)) + { + sock->pending_events |= event; + sock->reported_events |= event; + sock->errors[event_bit] = error; + } }
static void sock_dispatch_events( struct sock *sock, int prevstate, int event, int error )