Zebediah Figura : ws2_32: Use IOCTL_AFD_WINE_FIONBIO.
Alexandre Julliard
julliard at winehq.org
Wed Jun 2 16:27:43 CDT 2021
Module: wine
Branch: master
Commit: a70c5172c6bb0e61ad24c202a9bf4e88b8c868b0
URL: https://source.winehq.org/git/wine.git/?a=commit;h=a70c5172c6bb0e61ad24c202a9bf4e88b8c868b0
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Wed Jun 2 10:30:16 2021 -0500
ws2_32: Use IOCTL_AFD_WINE_FIONBIO.
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ws2_32/socket.c | 89 +++++++++++++-----------------------------------
dlls/ws2_32/tests/sock.c | 17 ++++-----
2 files changed, 30 insertions(+), 76 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index c1f415444df..0fc13344ee2 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -798,35 +798,6 @@ static inline void release_sock_fd( SOCKET s, int fd )
close( fd );
}
-static void _enable_event( HANDLE s, unsigned int event,
- unsigned int sstate, unsigned int cstate )
-{
- SERVER_START_REQ( enable_socket_event )
- {
- req->handle = wine_server_obj_handle( s );
- req->mask = event;
- req->sstate = sstate;
- req->cstate = cstate;
- wine_server_call( req );
- }
- SERVER_END_REQ;
-}
-
-static unsigned int _get_sock_mask(SOCKET s)
-{
- unsigned int ret;
- SERVER_START_REQ( get_socket_event )
- {
- req->handle = wine_server_obj_handle( SOCKET2HANDLE(s) );
- req->service = FALSE;
- req->c_event = 0;
- wine_server_call( req );
- ret = reply->mask;
- }
- SERVER_END_REQ;
- return ret;
-}
-
static void _get_sock_errors(SOCKET s, int *events)
{
SERVER_START_REQ( get_socket_event )
@@ -3371,23 +3342,20 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
switch (code)
{
case WS_FIONBIO:
- if (in_size != sizeof(WS_u_long) || IS_INTRESOURCE(in_buff))
- {
- SetLastError(WSAEFAULT);
- return SOCKET_ERROR;
- }
- TRACE("-> FIONBIO (%x)\n", *(WS_u_long*)in_buff);
- if (_get_sock_mask(s))
+ {
+ DWORD ret;
+
+ if (IS_INTRESOURCE( in_buff ))
{
- /* AsyncSelect()'ed sockets are always nonblocking */
- if (!*(WS_u_long *)in_buff) status = WSAEINVAL;
- break;
+ SetLastError( WSAEFAULT );
+ return -1;
}
- if (*(WS_u_long *)in_buff)
- _enable_event(SOCKET2HANDLE(s), 0, FD_WINE_NONBLOCKING, 0);
- else
- _enable_event(SOCKET2HANDLE(s), 0, 0, FD_WINE_NONBLOCKING);
- break;
+
+ ret = server_ioctl_sock( s, IOCTL_AFD_WINE_FIONBIO, in_buff, in_size,
+ out_buff, out_size, ret_size, overlapped, completion );
+ SetLastError( ret );
+ return ret ? -1 : 0;
+ }
case WS_FIONREAD:
{
@@ -3684,34 +3652,23 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
case 0x667e: /* Netscape tries hard to use bogus ioctl 0x667e */
SetLastError(WSAEOPNOTSUPP);
return SOCKET_ERROR;
+
case WS_SIO_ADDRESS_LIST_CHANGE:
- code = IOCTL_AFD_WINE_ADDRESS_LIST_CHANGE;
- status = WSAEOPNOTSUPP;
- break;
+ {
+ DWORD ret;
+
+ ret = server_ioctl_sock( s, IOCTL_AFD_WINE_ADDRESS_LIST_CHANGE, in_buff, in_size,
+ out_buff, out_size, ret_size, overlapped, completion );
+ SetLastError( ret );
+ return ret ? -1 : 0;
+ }
+
default:
+ FIXME( "unimplemented ioctl %s\n", debugstr_wsaioctl( code ) );
status = WSAEOPNOTSUPP;
break;
}
- if (status == WSAEOPNOTSUPP)
- {
- status = server_ioctl_sock(s, code, in_buff, in_size, out_buff, out_size, &total,
- overlapped, completion);
- if (status != WSAEOPNOTSUPP)
- {
- if (status == 0 || status == WSA_IO_PENDING || status == WSAEWOULDBLOCK)
- TRACE("-> %s request\n", debugstr_wsaioctl(code));
- else
- ERR("-> %s request failed with status 0x%x\n", debugstr_wsaioctl(code), status);
-
- /* overlapped and completion operations will be handled by the server */
- completion = NULL;
- overlapped = NULL;
- }
- else
- FIXME("unsupported WS_IOCTL cmd (%s)\n", debugstr_wsaioctl(code));
- }
-
if (completion)
{
FIXME( "completion routine %p not supported\n", completion );
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index bf8d028611f..fe7f155a8d8 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -3931,11 +3931,11 @@ static void test_fionbio(void)
WSASetLastError(0xdeadbeef);
ret = WSAIoctl(s, FIONBIO, &one, sizeof(one), NULL, 0, &size, NULL, NULL);
ok(!ret, "expected success\n");
- todo_wine ok(!WSAGetLastError(), "got error %u\n", WSAGetLastError());
+ ok(!WSAGetLastError(), "got error %u\n", WSAGetLastError());
ok(!size, "got size %u\n", size);
ret = WSAIoctl(s, FIONBIO, &one, sizeof(one) + 1, NULL, 0, &size, NULL, NULL);
- todo_wine ok(!ret, "got error %u\n", WSAGetLastError());
+ ok(!ret, "got error %u\n", WSAGetLastError());
overlapped.Internal = 0xdeadbeef;
overlapped.InternalHigh = 0xdeadbeef;
@@ -3984,14 +3984,11 @@ static void test_fionbio(void)
ok(!size, "got size %u\n", size);
ret = SleepEx(0, TRUE);
- todo_wine ok(ret == WAIT_IO_COMPLETION, "got %d\n", ret);
- if (ret == WAIT_IO_COMPLETION)
- {
- ok(apc_count == 1, "APC was called %u times\n", apc_count);
- ok(!apc_error, "got APC error %u\n", apc_error);
- ok(!apc_size, "got APC size %u\n", apc_size);
- ok(apc_overlapped == &overlapped, "got APC overlapped %p\n", apc_overlapped);
- }
+ ok(ret == WAIT_IO_COMPLETION, "got %d\n", ret);
+ ok(apc_count == 1, "APC was called %u times\n", apc_count);
+ ok(!apc_error, "got APC error %u\n", apc_error);
+ ok(!apc_size, "got APC size %u\n", apc_size);
+ ok(apc_overlapped == &overlapped, "got APC overlapped %p\n", apc_overlapped);
closesocket(s);
}
More information about the wine-cvs
mailing list