Added patch to properly close sockets when WSACleanup is called.

This commit is contained in:
Sebastian Lackner 2015-09-05 04:29:38 +02:00
parent 426191d7fb
commit 49c01cab8a
5 changed files with 131 additions and 1 deletions

View File

@ -39,7 +39,7 @@ Wine. All those differences are also documented on the
Included bug fixes and improvements
-----------------------------------
**Bug fixes and features included in the next upcoming release [16]:**
**Bug fixes and features included in the next upcoming release [17]:**
* Add stub for dwmapi.DwmUpdateThumbnailProperties
* Add stub for winspool.SetPrinterW level 8 ([Wine Bug #24645](https://bugs.winehq.org/show_bug.cgi?id=24645))
@ -53,6 +53,7 @@ Included bug fixes and improvements
* Implement a Courier New replacement font ([Wine Bug #20456](https://bugs.winehq.org/show_bug.cgi?id=20456))
* Implement a Times New Roman replacement font ([Wine Bug #32342](https://bugs.winehq.org/show_bug.cgi?id=32342))
* Map EXDEV error code to STATUS_NOT_SAME_DEVICE
* Properly close sockets when WSACleanup is called ([Wine Bug #18670](https://bugs.winehq.org/show_bug.cgi?id=18670))
* Return a dummy BIOS name in Win32_BIOS record
* SHFileOperation with FO_MOVE should create new directory on Vista+ ([Wine Bug #25207](https://bugs.winehq.org/show_bug.cgi?id=25207))
* Translate flags in LaunchINFSectionW

1
debian/changelog vendored
View File

@ -30,6 +30,7 @@ wine-staging (1.7.51) UNRELEASED; urgency=low
* Added patch for stub of dwmapi.DwmUpdateThumbnailProperties.
* Added patch to use proper glyph names in wineps driver (which fixes a bug
related to copying text from generated PDF files).
* Added patch to properly close sockets when WSACleanup is called.
* Removed patch to fix bug in wineserver debug_children inheritance (accepted
upstream).
* Removed patch to use helper function for NtWaitForMultipleObjects and

View File

@ -318,6 +318,7 @@ patch_enable_all ()
enable_ws2_32_APC_Performance="$1"
enable_ws2_32_Connect_Time="$1"
enable_ws2_32_TransmitFile="$1"
enable_ws2_32_WSACleanup="$1"
enable_ws2_32_WSAPoll="$1"
enable_ws2_32_WriteWatches="$1"
enable_ws2_32_getaddrinfo="$1"
@ -1045,6 +1046,9 @@ patch_enable ()
ws2_32-TransmitFile)
enable_ws2_32_TransmitFile="$2"
;;
ws2_32-WSACleanup)
enable_ws2_32_WSACleanup="$2"
;;
ws2_32-WSAPoll)
enable_ws2_32_WSAPoll="$2"
;;
@ -6378,6 +6382,21 @@ if test "$enable_ws2_32_TransmitFile" -eq 1; then
) >> "$patchlist"
fi
# Patchset ws2_32-WSACleanup
# |
# | This patchset fixes the following Wine bugs:
# | * [#18670] Properly close sockets when WSACleanup is called
# |
# | Modified files:
# | * dlls/ws2_32/socket.c, dlls/ws2_32/tests/sock.c, server/protocol.def, server/sock.c
# |
if test "$enable_ws2_32_WSACleanup" -eq 1; then
patch_apply ws2_32-WSACleanup/0001-ws2_32-Proper-WSACleanup-implementation-using-winese.patch
(
echo '+ { "Matt Durgavich", "ws2_32: Proper WSACleanup implementation using wineserver function.", 2 },';
) >> "$patchlist"
fi
# Patchset ws2_32-WSAPoll
# |
# | This patchset fixes the following Wine bugs:

View File

@ -0,0 +1,108 @@
From 0002cf1a076fddb1eecef95f1177ae6562cda785 Mon Sep 17 00:00:00 2001
From: Matt Durgavich <mattdurgavich@gmail.com>
Date: Sun, 30 Aug 2015 11:04:08 -0400
Subject: ws2_32: Proper WSACleanup implementation using wineserver function
(try 2)
---
dlls/ws2_32/socket.c | 22 ++++++++++++++++------
dlls/ws2_32/tests/sock.c | 5 ++---
server/protocol.def | 3 +++
server/sock.c | 9 +++++++++
4 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index ca82ec9..f153de1 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -1469,13 +1469,23 @@ int WINAPI WSAStartup(WORD wVersionRequested, LPWSADATA lpWSAData)
*/
INT WINAPI WSACleanup(void)
{
- if (num_startup) {
- num_startup--;
- TRACE("pending cleanups: %d\n", num_startup);
- return 0;
+ if (!num_startup)
+ {
+ SetLastError(WSANOTINITIALISED);
+ return SOCKET_ERROR;
}
- SetLastError(WSANOTINITIALISED);
- return SOCKET_ERROR;
+
+ if (!--num_startup)
+ {
+ SERVER_START_REQ(socket_cleanup)
+ {
+ wine_server_call( req );
+ }
+ SERVER_END_REQ;
+ }
+
+ TRACE("pending cleanups: %d\n", num_startup);
+ return 0;
}
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 2d14496..204b852 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -1119,20 +1119,19 @@ 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(src, "TEST", 4, 0);
error = WSAGetLastError();
ok(res == SOCKET_ERROR, "send should have failed\n");
+ todo_wine
ok(error == WSAENOTSOCK, "expected 10038, got %d\n", error);
SetLastError(0xdeadbeef);
res = closesocket(dst);
error = WSAGetLastError();
ok(res == SOCKET_ERROR, "closesocket should have failed\n");
+ todo_wine
ok(error == WSAENOTSOCK, "expected 10038, got %d\n", error);
- }
-
closesocket(src);
closesocket(dst);
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 */
+@REQ(socket_cleanup)
+@END
/* Set a handle information */
@REQ(set_handle_info)
diff --git a/server/sock.c b/server/sock.c
index 67d6416e..98f8176 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -1383,3 +1383,12 @@ DECL_HANDLER(get_socket_info)
release_object( &sock->obj );
}
+
+DECL_HANDLER(socket_cleanup)
+{
+ unsigned int index = 0;
+ obj_handle_t sock;
+
+ while ((sock = enumerate_handles(current->process, &sock_ops, &index)))
+ close_handle(current->process, sock);
+}
--
2.5.1

View File

@ -0,0 +1 @@
Fixes: [18670] Properly close sockets when WSACleanup is called