Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/unix/socket.c | 22 ++++++++++++++++++++++ dlls/ws2_32/socket.c | 23 +++++------------------ include/wine/afd.h | 1 + 3 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index 7b62c5aef68..89926411a40 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -1613,6 +1613,28 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc case IOCTL_AFD_WINE_SET_SO_KEEPALIVE: return do_setsockopt( handle, io, SOL_SOCKET, SO_KEEPALIVE, in_buffer, in_size );
+ case IOCTL_AFD_WINE_GET_SO_LINGER: + { + struct WS_linger *ws_linger = out_buffer; + struct linger unix_linger; + socklen_t len = sizeof(unix_linger); + int ret; + + if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) + return status; + + ret = getsockopt( fd, SOL_SOCKET, SO_LINGER, &unix_linger, &len ); + if (needs_close) close( fd ); + if (!ret) + { + ws_linger->l_onoff = unix_linger.l_onoff; + ws_linger->l_linger = unix_linger.l_linger; + io->Information = sizeof(*ws_linger); + } + + 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 c35972c1d27..de83563bd29 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -2229,9 +2229,6 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
case WS_SO_LINGER: { - struct linger lingval; - socklen_t len = sizeof(struct linger); - /* struct linger and LINGER have different sizes */ if (!optlen || *optlen < sizeof(LINGER) || !optval) { @@ -2243,23 +2240,13 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
if (_get_fd_type(fd) == SOCK_DGRAM) { - SetLastError(WSAENOPROTOOPT); - ret = SOCKET_ERROR; + release_sock_fd( s, fd ); + SetLastError( WSAENOPROTOOPT ); + return -1; } - else if (getsockopt(fd, SOL_SOCKET, SO_LINGER, &lingval, &len) != 0) - { - SetLastError(wsaErrno()); - ret = SOCKET_ERROR; - } - else - { - ((LINGER *)optval)->l_onoff = lingval.l_onoff; - ((LINGER *)optval)->l_linger = lingval.l_linger; - *optlen = sizeof(struct linger); - } - release_sock_fd( s, fd ); - return ret; + + return server_getsockopt( s, IOCTL_AFD_WINE_GET_SO_LINGER, optval, optlen ); }
case WS_SO_MAX_MSG_SIZE: diff --git a/include/wine/afd.h b/include/wine/afd.h index 616ba27b679..f1dd392ed32 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -165,6 +165,7 @@ struct afd_get_events_params #define IOCTL_AFD_WINE_GET_SO_ERROR CTL_CODE(FILE_DEVICE_NETWORK, 222, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_GET_SO_KEEPALIVE CTL_CODE(FILE_DEVICE_NETWORK, 223, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_SET_SO_KEEPALIVE CTL_CODE(FILE_DEVICE_NETWORK, 224, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_AFD_WINE_GET_SO_LINGER CTL_CODE(FILE_DEVICE_NETWORK, 225, METHOD_BUFFERED, FILE_ANY_ACCESS)
struct afd_create_params {
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/unix/socket.c | 11 +++++++++++ dlls/ws2_32/socket.c | 17 +++-------------- include/wine/afd.h | 1 + 3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index 89926411a40..c809dc17d13 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -1635,6 +1635,17 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc return ret ? sock_errno_to_status( errno ) : STATUS_SUCCESS; }
+ case IOCTL_AFD_WINE_SET_SO_LINGER: + { + const struct WS_linger *ws_linger = in_buffer; + struct linger unix_linger; + + unix_linger.l_onoff = ws_linger->l_onoff; + unix_linger.l_linger = ws_linger->l_linger; + + return do_setsockopt( handle, io, SOL_SOCKET, SO_LINGER, &unix_linger, sizeof(unix_linger) ); + } + default: { if ((code >> 16) == FILE_DEVICE_NETWORK) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index de83563bd29..3925a7ed500 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -3545,6 +3545,9 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname, case WS_SO_KEEPALIVE: return server_setsockopt( s, IOCTL_AFD_WINE_SET_SO_KEEPALIVE, optval, optlen );
+ case WS_SO_LINGER: + return server_setsockopt( s, IOCTL_AFD_WINE_SET_SO_LINGER, 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 @@ -3564,20 +3567,6 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname, optlen = sizeof(struct linger); break;
- case WS_SO_LINGER: - if (!optval) - { - SetLastError(WSAEFAULT); - return SOCKET_ERROR; - } - linger.l_onoff = ((LINGER*)optval)->l_onoff; - linger.l_linger = ((LINGER*)optval)->l_linger; - level = SOL_SOCKET; - optname = SO_LINGER; - optval = (char*)&linger; - optlen = sizeof(struct linger); - break; - case WS_SO_SNDBUF: if (!*(const int *)optval) { diff --git a/include/wine/afd.h b/include/wine/afd.h index f1dd392ed32..9ffdf491ac6 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -166,6 +166,7 @@ struct afd_get_events_params #define IOCTL_AFD_WINE_GET_SO_KEEPALIVE CTL_CODE(FILE_DEVICE_NETWORK, 223, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_SET_SO_KEEPALIVE CTL_CODE(FILE_DEVICE_NETWORK, 224, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_GET_SO_LINGER CTL_CODE(FILE_DEVICE_NETWORK, 225, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_AFD_WINE_SET_SO_LINGER CTL_CODE(FILE_DEVICE_NETWORK, 226, METHOD_BUFFERED, FILE_ANY_ACCESS)
struct afd_create_params {
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=93075
Your paranoid android.
=== debiant2 (32 bit WoW report) ===
ws2_32: sock.c:5787: Test succeeded inside todo block: expected failure sock.c:5788: Test succeeded inside todo block: got error 64
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ws2_32/socket.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 3925a7ed500..112376e583c 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -2162,29 +2162,21 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
case WS_SO_DONTLINGER: { - struct linger lingval; - socklen_t len = sizeof(struct linger); + struct WS_linger linger; + int len = sizeof(linger); + int ret;
if (!optlen || *optlen < sizeof(BOOL)|| !optval) { SetLastError(WSAEFAULT); return SOCKET_ERROR; } - if ( (fd = get_sock_fd( s, 0, NULL )) == -1) - return SOCKET_ERROR;
- if (getsockopt(fd, SOL_SOCKET, SO_LINGER, &lingval, &len) != 0 ) + if (!(ret = WS_getsockopt( s, WS_SOL_SOCKET, WS_SO_LINGER, (char *)&linger, &len ))) { - SetLastError(wsaErrno()); - ret = SOCKET_ERROR; - } - else - { - *(BOOL *)optval = !lingval.l_onoff; + *(BOOL *)optval = !linger.l_onoff; *optlen = sizeof(BOOL); } - - release_sock_fd( s, fd ); return ret; }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ws2_32/socket.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 112376e583c..776268b381a 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -3506,7 +3506,6 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname, { int fd; int woptval; - struct linger linger; struct timeval tval; struct ip_mreq_source mreq_source;
@@ -3529,6 +3528,21 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname, case WS_SO_BROADCAST: return server_setsockopt( s, IOCTL_AFD_WINE_SET_SO_BROADCAST, optval, optlen );
+ case WS_SO_DONTLINGER: + { + struct WS_linger linger; + + if (!optval) + { + SetLastError( WSAEFAULT ); + return -1; + } + + linger.l_onoff = !*(const BOOL *)optval; + linger.l_linger = 0; + return WS_setsockopt( s, WS_SOL_SOCKET, WS_SO_LINGER, (char *)&linger, sizeof(linger) ); + } + case WS_SO_ERROR: FIXME( "SO_ERROR, stub!\n" ); SetLastError( WSAENOPROTOOPT ); @@ -3545,20 +3559,6 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname, * to the general case. Special options that are not passed to * setsockopt follow below that.*/
- case WS_SO_DONTLINGER: - if (!optval) - { - SetLastError(WSAEFAULT); - return SOCKET_ERROR; - } - linger.l_onoff = *(const int*)optval == 0; - linger.l_linger = 0; - level = SOL_SOCKET; - optname = SO_LINGER; - optval = (char*)&linger; - optlen = sizeof(struct linger); - break; - case WS_SO_SNDBUF: if (!*(const int *)optval) {
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/unix/socket.c | 3 +++ dlls/ws2_32/socket.c | 4 +++- include/wine/afd.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index c809dc17d13..917f883a0f5 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -1646,6 +1646,9 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc return do_setsockopt( handle, io, SOL_SOCKET, SO_LINGER, &unix_linger, sizeof(unix_linger) ); }
+ case IOCTL_AFD_WINE_GET_SO_OOBINLINE: + return do_getsockopt( handle, io, SOL_SOCKET, SO_OOBINLINE, out_buffer, out_size ); + default: { if ((code >> 16) == FILE_DEVICE_NETWORK) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 776268b381a..0301454657a 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -2090,7 +2090,6 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
/* Handle common cases. The special cases are below, sorted * alphabetically */ - case WS_SO_OOBINLINE: case WS_SO_RCVBUF: case WS_SO_REUSEADDR: case WS_SO_SNDBUF: @@ -2252,6 +2251,9 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, *optlen = sizeof(int); return 0;
+ case WS_SO_OOBINLINE: + return server_getsockopt( s, IOCTL_AFD_WINE_GET_SO_OOBINLINE, optval, optlen ); + /* SO_OPENTYPE does not require a valid socket handle. */ case WS_SO_OPENTYPE: if (!optlen || *optlen < sizeof(int) || !optval) diff --git a/include/wine/afd.h b/include/wine/afd.h index 9ffdf491ac6..fec4db4db94 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -167,6 +167,7 @@ struct afd_get_events_params #define IOCTL_AFD_WINE_SET_SO_KEEPALIVE CTL_CODE(FILE_DEVICE_NETWORK, 224, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_GET_SO_LINGER CTL_CODE(FILE_DEVICE_NETWORK, 225, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_SET_SO_LINGER CTL_CODE(FILE_DEVICE_NETWORK, 226, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_AFD_WINE_GET_SO_OOBINLINE CTL_CODE(FILE_DEVICE_NETWORK, 227, METHOD_BUFFERED, FILE_ANY_ACCESS)
struct afd_create_params {
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=93078
Your paranoid android.
=== debiant2 (32 bit report) ===
ws2_32: sock.c:5787: Test succeeded inside todo block: expected failure sock.c:5788: Test succeeded inside todo block: got error 64
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/unix/socket.c | 3 +++ dlls/ws2_32/socket.c | 4 +++- include/wine/afd.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index 917f883a0f5..0ab30ec6515 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -1649,6 +1649,9 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc case IOCTL_AFD_WINE_GET_SO_OOBINLINE: return do_getsockopt( handle, io, SOL_SOCKET, SO_OOBINLINE, out_buffer, out_size );
+ case IOCTL_AFD_WINE_SET_SO_OOBINLINE: + return do_setsockopt( handle, io, SOL_SOCKET, SO_OOBINLINE, in_buffer, in_size ); + default: { if ((code >> 16) == FILE_DEVICE_NETWORK) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 0301454657a..88d8e9bf134 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -3556,6 +3556,9 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname, case WS_SO_LINGER: return server_setsockopt( s, IOCTL_AFD_WINE_SET_SO_LINGER, optval, optlen );
+ case WS_SO_OOBINLINE: + return server_setsockopt( s, IOCTL_AFD_WINE_SET_SO_OOBINLINE, 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 @@ -3583,7 +3586,6 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname, /* 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.*/ - case WS_SO_OOBINLINE: /* 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 */ diff --git a/include/wine/afd.h b/include/wine/afd.h index fec4db4db94..ae5a0584bdc 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -168,6 +168,7 @@ struct afd_get_events_params #define IOCTL_AFD_WINE_GET_SO_LINGER CTL_CODE(FILE_DEVICE_NETWORK, 225, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_SET_SO_LINGER CTL_CODE(FILE_DEVICE_NETWORK, 226, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_GET_SO_OOBINLINE CTL_CODE(FILE_DEVICE_NETWORK, 227, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_AFD_WINE_SET_SO_OOBINLINE CTL_CODE(FILE_DEVICE_NETWORK, 228, METHOD_BUFFERED, FILE_ANY_ACCESS)
struct afd_create_params {
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=93079
Your paranoid android.
=== debiant2 (64 bit WoW report) ===
ws2_32: sock.c:5787: Test succeeded inside todo block: expected failure sock.c:5788: Test succeeded inside todo block: got error 64