Commit 93863d25 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ws2_32: Pass completion routing to NtDeviceIoControlFile in server_ioctl_sock…

ws2_32: Pass completion routing to NtDeviceIoControlFile in server_ioctl_sock only if caller provided completion routine. Otherwise we're always doing non-blocking calls, preventing server from doing the right thing (and in actually doing the opposite in WS_SIO_ADDRESS_LIST_CHANGE case). Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent f1ef14e0
...@@ -4520,18 +4520,27 @@ static DWORD server_ioctl_sock( SOCKET s, DWORD code, LPVOID in_buff, DWORD in_s ...@@ -4520,18 +4520,27 @@ static DWORD server_ioctl_sock( SOCKET s, DWORD code, LPVOID in_buff, DWORD in_s
{ {
HANDLE event = overlapped ? overlapped->hEvent : 0; HANDLE event = overlapped ? overlapped->hEvent : 0;
HANDLE handle = SOCKET2HANDLE( s ); HANDLE handle = SOCKET2HANDLE( s );
struct ws2_async *wsa; struct ws2_async *wsa = NULL;
IO_STATUS_BLOCK *io = (PIO_STATUS_BLOCK)overlapped, iosb;
void *cvalue = NULL;
NTSTATUS status; NTSTATUS status;
PIO_STATUS_BLOCK io;
if (!(wsa = (struct ws2_async *)alloc_async_io( sizeof(*wsa) ))) if (completion)
return WSA_NOT_ENOUGH_MEMORY; {
wsa->hSocket = handle; if (!(wsa = (struct ws2_async *)alloc_async_io( sizeof(*wsa) )))
wsa->user_overlapped = overlapped; return WSA_NOT_ENOUGH_MEMORY;
wsa->completion_func = completion; wsa->hSocket = handle;
io = (overlapped ? (PIO_STATUS_BLOCK)overlapped : &wsa->local_iosb); wsa->user_overlapped = overlapped;
wsa->completion_func = completion;
if (!io) io = &wsa->local_iosb;
cvalue = wsa;
}
else if (!io)
io = &iosb;
else if (!((ULONG_PTR)overlapped->hEvent & 1))
cvalue = overlapped;
status = NtDeviceIoControlFile( handle, event, ws2_async_apc, wsa, io, code, status = NtDeviceIoControlFile( handle, event, wsa ? ws2_async_apc : NULL, cvalue, io, code,
in_buff, in_size, out_buff, out_size ); in_buff, in_size, out_buff, out_size );
if (status == STATUS_NOT_SUPPORTED) if (status == STATUS_NOT_SUPPORTED)
{ {
......
...@@ -8387,7 +8387,6 @@ static void test_sioAddressListChange(void) ...@@ -8387,7 +8387,6 @@ static void test_sioAddressListChange(void)
ret = WSAIoctl(sock, SIO_ADDRESS_LIST_CHANGE, NULL, 0, NULL, 0, &num_bytes, &overlapped, NULL); ret = WSAIoctl(sock, SIO_ADDRESS_LIST_CHANGE, NULL, 0, NULL, 0, &num_bytes, &overlapped, NULL);
error = GetLastError(); error = GetLastError();
ok (ret == SOCKET_ERROR, "WSAIoctl(SIO_ADDRESS_LIST_CHANGE) failed with error %d\n", error); ok (ret == SOCKET_ERROR, "WSAIoctl(SIO_ADDRESS_LIST_CHANGE) failed with error %d\n", error);
todo_wine
ok (error == ERROR_IO_PENDING, "expected 0x3e5, got 0x%x\n", error); ok (error == ERROR_IO_PENDING, "expected 0x3e5, got 0x%x\n", error);
CloseHandle(overlapped.hEvent); CloseHandle(overlapped.hEvent);
...@@ -8426,7 +8425,6 @@ todo_wine ...@@ -8426,7 +8425,6 @@ todo_wine
ret = WSAIoctl(sock, SIO_ADDRESS_LIST_CHANGE, NULL, 0, NULL, 0, &num_bytes, &overlapped, NULL); ret = WSAIoctl(sock, SIO_ADDRESS_LIST_CHANGE, NULL, 0, NULL, 0, &num_bytes, &overlapped, NULL);
error = GetLastError(); error = GetLastError();
ok (ret == SOCKET_ERROR, "WSAIoctl(SIO_ADDRESS_LIST_CHANGE) failed with error %d\n", error); ok (ret == SOCKET_ERROR, "WSAIoctl(SIO_ADDRESS_LIST_CHANGE) failed with error %d\n", error);
todo_wine
ok (error == ERROR_IO_PENDING, "expected 0x3e5, got 0x%x\n", error); ok (error == ERROR_IO_PENDING, "expected 0x3e5, got 0x%x\n", error);
CloseHandle(overlapped.hEvent); CloseHandle(overlapped.hEvent);
......
...@@ -548,7 +548,7 @@ obj_handle_t sock_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *a ...@@ -548,7 +548,7 @@ obj_handle_t sock_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *a
switch(code) switch(code)
{ {
case WS_SIO_ADDRESS_LIST_CHANGE: case WS_SIO_ADDRESS_LIST_CHANGE:
if ((sock->state & FD_WINE_NONBLOCKING) && !blocking) if ((sock->state & FD_WINE_NONBLOCKING) && blocking)
{ {
set_error( STATUS_CANT_WAIT ); set_error( STATUS_CANT_WAIT );
return 0; return 0;
......
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