Module: wine
Branch: master
Commit: 252d564c7b604c49397d92755bcc174b34afc295
URL: https://source.winehq.org/git/wine.git/?a=commit;h=252d564c7b604c49397d9275…
Author: Zebediah Figura <z.figura12(a)gmail.com>
Date: Tue Jun 29 23:25:41 2021 -0500
ws2_32: Use IOCTL_AFD_WINE_SET_SO_SNDBUF.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
dlls/ws2_32/socket.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 89fb7d3462b..3f15bb4e39b 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -3575,21 +3575,8 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname,
case WS_SO_REUSEADDR:
return server_setsockopt( s, IOCTL_AFD_WINE_SET_SO_REUSEADDR, optval, optlen );
- /* Some options need some conversion before they can be sent to
- * setsockopt. The conversions are done here, then they will fall through
- * to the general case. Special options that are not passed to
- * setsockopt follow below that.*/
-
case WS_SO_SNDBUF:
- if (!*(const int *)optval)
- {
- FIXME("SO_SNDBUF ignoring request to disable send buffering\n");
-#ifdef __APPLE__
- return 0;
-#endif
- }
- convert_sockopt(&level, &optname);
- break;
+ return server_setsockopt( s, IOCTL_AFD_WINE_SET_SO_SNDBUF, optval, optlen );
/* SO_DEBUG is a privileged operation, ignore it. */
case WS_SO_DEBUG:
Module: wine
Branch: master
Commit: 9eea22f724465d3cc9be1746a7602161e9e522aa
URL: https://source.winehq.org/git/wine.git/?a=commit;h=9eea22f724465d3cc9be1746…
Author: Zebediah Figura <z.figura12(a)gmail.com>
Date: Tue Jun 29 11:43:22 2021 -0500
ws2_32: Move the setsockopt(SO_REUSEADDR) implementation to ntdll.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
dlls/ntdll/unix/socket.c | 20 ++++++++++++++++++++
dlls/ws2_32/socket.c | 13 +++----------
include/wine/afd.h | 1 +
3 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c
index 549981388c7..38cb80997ff 100644
--- a/dlls/ntdll/unix/socket.c
+++ b/dlls/ntdll/unix/socket.c
@@ -1655,6 +1655,26 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc
case IOCTL_AFD_WINE_GET_SO_REUSEADDR:
return do_getsockopt( handle, io, SOL_SOCKET, SO_REUSEADDR, out_buffer, out_size );
+ /* BSD socket SO_REUSEADDR is not 100% compatible to winsock semantics;
+ * however, using it the BSD way fixes bug 8513 and seems to be what
+ * most programmers assume, anyway */
+ case IOCTL_AFD_WINE_SET_SO_REUSEADDR:
+ {
+ int fd, needs_close = FALSE;
+ NTSTATUS status;
+ int ret;
+
+ if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL )))
+ return status;
+
+ ret = setsockopt( fd, SOL_SOCKET, SO_REUSEADDR, in_buffer, in_size );
+#ifdef __APPLE__
+ if (!ret) ret = setsockopt( fd, SOL_SOCKET, SO_REUSEPORT, in_buffer, in_size );
+#endif
+ if (needs_close) close( fd );
+ return ret ? sock_errno_to_status( errno ) : STATUS_SUCCESS;
+ }
+
default:
{
if ((code >> 16) == FILE_DEVICE_NETWORK)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 11e6719fcb0..89fb7d3462b 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -3572,6 +3572,9 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname,
case WS_SO_RCVTIMEO:
return server_setsockopt( s, IOCTL_AFD_WINE_SET_SO_RCVTIMEO, optval, optlen );
+ case WS_SO_REUSEADDR:
+ return server_setsockopt( s, IOCTL_AFD_WINE_SET_SO_REUSEADDR, optval, optlen );
+
/* Some options need some conversion before they can be sent to
* setsockopt. The conversions are done here, then they will fall through
* to the general case. Special options that are not passed to
@@ -3588,16 +3591,6 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname,
convert_sockopt(&level, &optname);
break;
- /* The options listed here don't need any special handling. Thanks to
- * the conversion happening above, options from there will fall through
- * to this, too.*/
- /* BSD socket SO_REUSEADDR is not 100% compatible to winsock semantics.
- * however, using it the BSD way fixes bug 8513 and seems to be what
- * most programmers assume, anyway */
- case WS_SO_REUSEADDR:
- convert_sockopt(&level, &optname);
- break;
-
/* SO_DEBUG is a privileged operation, ignore it. */
case WS_SO_DEBUG:
TRACE("Ignoring SO_DEBUG\n");
diff --git a/include/wine/afd.h b/include/wine/afd.h
index f337ec361b2..d522b8a289f 100644
--- a/include/wine/afd.h
+++ b/include/wine/afd.h
@@ -174,6 +174,7 @@ struct afd_get_events_params
#define IOCTL_AFD_WINE_SET_SO_RCVTIMEO CTL_CODE(FILE_DEVICE_NETWORK, 231, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_AFD_WINE_GET_SO_RCVTIMEO CTL_CODE(FILE_DEVICE_NETWORK, 232, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_AFD_WINE_GET_SO_REUSEADDR CTL_CODE(FILE_DEVICE_NETWORK, 233, METHOD_BUFFERED, FILE_ANY_ACCESS)
+#define IOCTL_AFD_WINE_SET_SO_REUSEADDR CTL_CODE(FILE_DEVICE_NETWORK, 234, METHOD_BUFFERED, FILE_ANY_ACCESS)
struct afd_create_params
{