Commit 039f8b16 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

ntdll: Move SO_REUSEADDR handling to server.

parent c6da6919
......@@ -1977,27 +1977,6 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc
case IOCTL_AFD_WINE_SET_SO_OOBINLINE:
return do_setsockopt( handle, io, SOL_SOCKET, SO_OOBINLINE, in_buffer, in_size );
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 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
status = ret ? sock_errno_to_status( errno ) : STATUS_SUCCESS;
break;
}
case IOCTL_AFD_WINE_SET_IP_ADD_MEMBERSHIP:
return do_setsockopt( handle, io, IPPROTO_IP, IP_ADD_MEMBERSHIP, in_buffer, in_size );
......
......@@ -2905,6 +2905,29 @@ static void sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
return;
}
/* 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 reuse, ret;
if (get_req_data_size() < sizeof(reuse))
{
set_error( STATUS_BUFFER_TOO_SMALL );
return;
}
reuse = *(int *)get_req_data();
ret = setsockopt( unix_fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse) );
#ifdef __APPLE__
if (!ret) ret = setsockopt( unix_fd, SOL_SOCKET, SO_REUSEPORT, &reuse, sizeof(reuse) );
#endif
if (ret)
set_error( sock_get_ntstatus( errno ) );
return;
}
case IOCTL_AFD_WINE_GET_SO_SNDBUF:
{
int sndbuf = sock->sndbuf;
......@@ -2992,6 +3015,24 @@ static void sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
return;
}
case IOCTL_AFD_WINE_GET_SO_REUSEADDR:
{
int reuse;
socklen_t len = sizeof(reuse);
if (!get_reply_max_size())
{
set_error( STATUS_BUFFER_TOO_SMALL );
return;
}
if (!getsockopt( unix_fd, SOL_SOCKET, SO_REUSEADDR, &reuse, &len ))
set_reply_data( &reuse, min( sizeof(reuse), get_reply_max_size() ));
else
set_error( sock_get_ntstatus( errno ) );
return;
}
case IOCTL_AFD_POLL:
{
if (get_reply_max_size() < get_req_data_size())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment