Zebediah Figura : ws2_32: Close all open sockets in WSACleanup().

Alexandre Julliard julliard at winehq.org
Tue Mar 23 15:07:39 CDT 2021


Module: wine
Branch: oldstable
Commit: 51fb80556e392814f2eebeb3545d27b9edeff6ca
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=51fb80556e392814f2eebeb3545d27b9edeff6ca

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Thu Sep 10 16:17:15 2020 -0500

ws2_32: Close all open sockets in WSACleanup().

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=18670
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 470b9d037988cf5e79b039370e2c6c55daf3459c)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/ws2_32/socket.c     | 14 +++++++++++---
 dlls/ws2_32/tests/sock.c |  3 ---
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 4495d19a802..9dac32bf210 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -1768,9 +1768,17 @@ int WINAPI WSAStartup(WORD wVersionRequested, LPWSADATA lpWSAData)
  */
 INT WINAPI WSACleanup(void)
 {
-    if (num_startup) {
-        num_startup--;
-        TRACE("pending cleanups: %d\n", num_startup);
+    TRACE("decreasing startup count from %d\n", num_startup);
+    if (num_startup)
+    {
+        if (!--num_startup)
+        {
+            unsigned int i;
+
+            for (i = 0; i < socket_list_size; ++i)
+                CloseHandle(SOCKET2HANDLE(socket_list[i]));
+            memset(socket_list, 0, socket_list_size * sizeof(*socket_list));
+        }
         return 0;
     }
     SetLastError(WSANOTINITIALISED);
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 15954b0fa91..305258deea7 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -1218,7 +1218,6 @@ 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(pairs[0].src, "TEST", 4, 0);
     error = WSAGetLastError();
@@ -1255,8 +1254,6 @@ static void test_WithWSAStartup(void)
         }
     }
 
-    }
-
     /* While wine is not fixed, close all sockets manually */
     for (i = 0; i < socks; i++)
     {




More information about the wine-cvs mailing list