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@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-09-10 16:17:15 -05:00 committed by Alexandre Julliard
parent 23dbfaadbb
commit 470b9d0379
2 changed files with 11 additions and 6 deletions

View File

@ -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);

View File

@ -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++)
{