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 {