Another try, this time server side. It was much simpler to do
--- dlls/ws2_32/socket.c | 13 ++++++++++++- server/handle.c | 12 ++++++++++++ server/protocol.def | 3 +++ server/sock.c | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index ca82ec9..66d5b2b 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -1471,7 +1471,18 @@ INT WINAPI WSACleanup(void) { if (num_startup) { num_startup--; - TRACE("pending cleanups: %d\n", num_startup); + if (num_startup == 0) + { + SERVER_START_REQ(close_all_sockets) + { + wine_server_call( req ); + } + SERVER_END_REQ; + } + else + { + TRACE("pending cleanups: %d\n", num_startup); + } return 0; } SetLastError(WSANOTINITIALISED); diff --git a/server/handle.c b/server/handle.c index 5043ff7..b4b5ecb 100644 --- a/server/handle.c +++ b/server/handle.c @@ -39,6 +39,8 @@ #include "security.h" #include "request.h"
+extern struct object_ops sock_ops; + struct handle_entry { struct object *ptr; /* object */ @@ -608,6 +610,16 @@ DECL_HANDLER(set_handle_info) reply->old_flags = set_handle_flags( current->process, req->handle, req->mask, req->flags ); }
+DECL_HANDLER(close_all_sockets) +{ + obj_handle_t sock; + UINT index = 0; + while ( (sock = enumerate_handles(current->process, &sock_ops, &index)) ) + { + close_handle(current->process, sock); + } +} + /* duplicate a handle */ DECL_HANDLER(dup_handle) { diff --git a/server/protocol.def b/server/protocol.def index c313006..651af47 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(close_all_sockets) +@END
/* Set a handle information */ @REQ(set_handle_info) diff --git a/server/sock.c b/server/sock.c index 67d6416..2a9f444 100644 --- a/server/sock.c +++ b/server/sock.c @@ -138,7 +138,7 @@ static int sock_get_ntstatus( int err ); static int sock_get_error( int err ); static void sock_set_error(void);
-static const struct object_ops sock_ops = +const struct object_ops sock_ops = { sizeof(struct sock), /* size */ sock_dump, /* dump */