From: Matt Durgavich Subject: WS2_32: WSACleanup implementation, server-side, plus remove todos around passing tests. This also fixes bug 32910 Message-Id: <67E6B896-2FCD-49C0-81EB-B1B735429678@gmail.com> Date: Sat, 29 Aug 2015 15:41:59 -0400 --- dlls/ws2_32/socket.c | 9 +++++++++ dlls/ws2_32/tests/sock.c | 5 ++--- server/protocol.def | 3 +++ server/sock.c | 10 ++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index ca82ec9..b5d5ff5 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -1471,6 +1471,15 @@ INT WINAPI WSACleanup(void) { if (num_startup) { num_startup--; + if (num_startup == 0) + { + SERVER_START_REQ(socket_cleanup) + { + wine_server_call( req ); + } + SERVER_END_REQ; + } + TRACE("pending cleanups: %d\n", num_startup); return 0; } diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 2d14496..c26d5b1 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -1119,20 +1119,19 @@ static void test_WithWSAStartup(void) ok(res == 0, "WSAStartup() failed unexpectedly: %d\n", res); /* show that sockets are destroyed automatically after WSACleanup */ - todo_wine { SetLastError(0xdeadbeef); res = send(src, "TEST", 4, 0); error = WSAGetLastError(); ok(res == SOCKET_ERROR, "send should have failed\n"); + todo_wine ok(error == WSAENOTSOCK, "expected 10038, got %d\n", error); SetLastError(0xdeadbeef); res = closesocket(dst); error = WSAGetLastError(); ok(res == SOCKET_ERROR, "closesocket should have failed\n"); + todo_wine ok(error == WSAENOTSOCK, "expected 10038, got %d\n", error); - } - closesocket(src); closesocket(dst); diff --git a/server/protocol.def b/server/protocol.def index c313006..2dccb9a 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -942,6 +942,9 @@ struct rawinput_device obj_handle_t handle; /* handle to close */ @END +/* Close all sockets for the current process */ +@REQ(socket_cleanup) +@END /* Set a handle information */ @REQ(set_handle_info) diff --git a/server/sock.c b/server/sock.c index 67d6416..c5c5083 100644 --- a/server/sock.c +++ b/server/sock.c @@ -1383,3 +1383,13 @@ DECL_HANDLER(get_socket_info) release_object( &sock->obj ); } + +DECL_HANDLER(socket_cleanup) +{ + obj_handle_t sock; + unsigned int index = 0; + while ( (sock = enumerate_handles(current->process, &sock_ops, &index)) ) + { + close_handle(current->process, sock); + } +} -- 2.3.2 (Apple Git-55)