ws2_32: WSACleanup cleans up open sockets (OSX only)

Matt Durgavich mattdurgavich at gmail.com
Sat Aug 29 13:13:01 CDT 2015


All suggestions rolled in. Removing todos in tests will be a separate patch

From d62ed3e109f6d6a862f62afb1242ca15e199fd98 Mon Sep 17 00:00:00 2001
From: Matt <matt at wymzee.com>
Date: Thu, 27 Aug 2015 23:43:59 -0400
Subject: [PATCH] WS2_32: WSACleanup implementation, server-side.

---
 dlls/ws2_32/socket.c |  9 +++++++++
 server/protocol.def  |  3 +++
 server/sock.c        | 10 ++++++++++
 3 files changed, 22 insertions(+)

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/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 */
+ at REQ(socket_cleanup)
+ at 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)

> On Aug 29, 2015, at 10:43 AM, Bruno Jesus <00cpxxx at gmail.com> wrote:
> 
> On Sat, Aug 29, 2015 at 6:28 AM, Matt Durgavich <mattdurgavich at gmail.com> wrote:
>> And the renaming patch
> 
> Please attach a single patch that is based against the original file,
> it's unnecessary harder to review an incremental patch.




More information about the wine-devel mailing list