Zebediah Figura : ws2_32: Close all open sockets in WSACleanup().
Alexandre Julliard
julliard at winehq.org
Fri Sep 11 14:51:45 CDT 2020
Module: wine
Branch: master
Commit: 470b9d037988cf5e79b039370e2c6c55daf3459c
URL: https://source.winehq.org/git/wine.git/?a=commit;h=470b9d037988cf5e79b039370e2c6c55daf3459c
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>
---
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 4421463029..246a0e2819 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -1770,9 +1770,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 c7f88d6f3b..7835246397 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -1221,7 +1221,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();
@@ -1258,8 +1257,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