Added patch to properly handle closing sockets during a select call.

This commit is contained in:
Sebastian Lackner 2015-04-16 13:02:10 +02:00
parent 5b313a54e2
commit 3a65a99375
5 changed files with 128 additions and 1 deletions

View File

@ -39,10 +39,11 @@ Wine. All those differences are also documented on the
Included bug fixes and improvements
-----------------------------------
**Bug fixes and features included in the next upcoming release [3]:**
**Bug fixes and features included in the next upcoming release [4]:**
* Calculate msvcrt exponential math operations with higher precision ([Wine Bug #37149](https://bugs.winehq.org/show_bug.cgi?id=37149))
* Fix regression caused by blacklisting supported OpenGL extensions ([Wine Bug #38264](https://bugs.winehq.org/show_bug.cgi?id=38264))
* Properly handle closing sockets during a select call ([Wine Bug #38399](https://bugs.winehq.org/show_bug.cgi?id=38399))
* Reset device state in SysKeyboard*Impl_Acquire ([Wine Bug #11607](https://bugs.winehq.org/show_bug.cgi?id=11607))

2
debian/changelog vendored
View File

@ -1,5 +1,6 @@
wine-staging (1.7.41) UNRELEASED; urgency=low
* Updated server-PeekMessage patchset to reset message filter in accept_hardware_message call (fixes Wine Staging Bug #211).
* Various improvements to the ACL patchsets.
* Disable DXVA2 controls in winecfg when support is not compiled in.
* Added patch to enable/disable EAX support via winecfg.
* Added patch with stub for setupapi.SetupDiSetDeviceInstallParamsW.
@ -7,6 +8,7 @@ wine-staging (1.7.41) UNRELEASED; urgency=low
* Added patch to calculate msvcrt exponential math operations with higher precision.
* Added patch to fix regression caused by blacklisting supported OpenGL extensions.
* Added patch to reset device state in SysKeyboard*Impl_Acquire.
* Added patch to properly handle closing sockets during a select call.
* Added tests for RtlIpv6AddressToString and RtlIpv6AddressToStringEx.
* Removed patches to fix invalid memory access in get_registry_locale_info (accepted upstream).
* Removed patches to avoid repeated FIXMEs in PsLookupProcessByProcessId stub (accepted upstream).

View File

@ -243,6 +243,7 @@ patch_enable_all ()
enable_wpcap_Dynamic_Linking="$1"
enable_ws2_32_APC_Performance="$1"
enable_ws2_32_Connect_Time="$1"
enable_ws2_32_Select="$1"
enable_ws2_32_TransmitFile="$1"
enable_ws2_32_WriteWatches="$1"
enable_ws2_32_getaddrinfo="$1"
@ -796,6 +797,9 @@ patch_enable ()
ws2_32-Connect_Time)
enable_ws2_32_Connect_Time="$2"
;;
ws2_32-Select)
enable_ws2_32_Select="$2"
;;
ws2_32-TransmitFile)
enable_ws2_32_TransmitFile="$2"
;;
@ -4782,6 +4786,21 @@ if test "$enable_ws2_32_Connect_Time" -eq 1; then
) >> "$patchlist"
fi
# Patchset ws2_32-Select
# |
# | This patchset fixes the following Wine bugs:
# | * [#38399] Properly handle closing sockets during a select call
# |
# | Modified files:
# | * dlls/ntdll/ntdll.spec, dlls/ntdll/server.c, dlls/ws2_32/socket.c, dlls/ws2_32/tests/sock.c, include/wine/server.h
# |
if test "$enable_ws2_32_Select" -eq 1; then
patch_apply ws2_32-Select/0001-ws2_32-Properly-handle-closing-sockets-during-a-sele.patch
(
echo '+ { "Sebastian Lackner", "ws2_32: Properly handle closing sockets during a select call.", 1 },';
) >> "$patchlist"
fi
# Patchset ws2_32-TransmitFile
# |
# | This patchset fixes the following Wine bugs:

View File

@ -0,0 +1,104 @@
From 2c467089a7cbb58f76375226314bd37d3e832e4d Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Thu, 16 Apr 2015 12:59:51 +0200
Subject: ws2_32: Properly handle closing sockets during a select call.
Based on a patch by Bruno Jesus.
---
dlls/ntdll/ntdll.spec | 1 +
dlls/ntdll/server.c | 21 +++++++++++++++++++++
dlls/ws2_32/socket.c | 8 +++++++-
dlls/ws2_32/tests/sock.c | 1 -
include/wine/server.h | 1 +
5 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index c3307b2..f47a24b 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -1416,6 +1416,7 @@
# Server interface
@ cdecl -norelay wine_server_call(ptr)
@ cdecl wine_server_fd_to_handle(long long long ptr)
+@ cdecl wine_server_handle_exists(long)
@ cdecl wine_server_handle_to_fd(long long ptr ptr)
@ cdecl wine_server_release_fd(long long)
@ cdecl wine_server_send_fd(long)
diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c
index 29cfcb5..237f439 100644
--- a/dlls/ntdll/server.c
+++ b/dlls/ntdll/server.c
@@ -1039,6 +1039,27 @@ int CDECL wine_server_fd_to_handle( int fd, unsigned int access, unsigned int at
/***********************************************************************
+ * wine_server_handle_exists (NTDLL.@)
+ *
+ * Checks if a file handle exists (without duplicating it).
+ *
+ * PARAMS
+ * handle [I] Wine file handle.
+ * access [I] Win32 file access rights requested.
+ *
+ * RETURNS
+ * NTSTATUS code
+ */
+int CDECL wine_server_handle_exists( HANDLE handle, unsigned int access )
+{
+ int unix_fd, needs_close, ret;
+ ret = server_get_unix_fd( handle, access, &unix_fd, &needs_close, NULL, NULL );
+ if (!ret && needs_close) close( unix_fd );
+ return !ret;
+}
+
+
+/***********************************************************************
* wine_server_handle_to_fd (NTDLL.@)
*
* Retrieve the file descriptor corresponding to a file handle.
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 95ea83c..ff21577 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -4788,7 +4788,13 @@ static void release_poll_fds( const WS_fd_set *readfds, const WS_fd_set *writefd
if (exceptfds)
{
for (i = 0; i < exceptfds->fd_count; i++, j++)
- if (fds[j].fd != -1) release_sock_fd( exceptfds->fd_array[i], fds[j].fd );
+ {
+ if (fds[j].fd == -1) continue;
+ release_sock_fd( exceptfds->fd_array[i], fds[j].fd );
+ if (!(fds[j].revents & POLLHUP)) continue;
+ if (wine_server_handle_exists( SOCKET2HANDLE( exceptfds->fd_array[i] ), 0 )) continue;
+ fds[j].revents = 0;
+ }
}
}
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index aa06a08..d276867 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -3834,7 +3834,6 @@ todo_wine
FD_ZERO_ALL();
FD_SET_ALL(fdWrite);
ret = select(0, &readfds, NULL, &exceptfds, &select_timeout);
-todo_wine
ok(ret == 1, "expected 1, got %d\n", ret);
ok(FD_ISSET(fdWrite, &readfds), "fdWrite socket is not in the set\n");
WaitForSingleObject (thread_handle, 1000);
diff --git a/include/wine/server.h b/include/wine/server.h
index d573d1f..a114cf9 100644
--- a/include/wine/server.h
+++ b/include/wine/server.h
@@ -52,6 +52,7 @@ struct __server_request_info
extern unsigned int wine_server_call( void *req_ptr );
extern void CDECL wine_server_send_fd( int fd );
extern int CDECL wine_server_fd_to_handle( int fd, unsigned int access, unsigned int attributes, HANDLE *handle );
+extern int CDECL wine_server_handle_exists( HANDLE handle, unsigned int access );
extern int CDECL wine_server_handle_to_fd( HANDLE handle, unsigned int access, int *unix_fd, unsigned int *options );
extern void CDECL wine_server_release_fd( HANDLE handle, int unix_fd );
--
2.3.5

View File

@ -0,0 +1 @@
Fixes: [38399] Properly handle closing sockets during a select call