Zebediah Figura : ws2_32: Use IOCTL_AFD_WINE_FIONREAD.

Alexandre Julliard julliard at winehq.org
Thu Jun 3 16:23:08 CDT 2021


Module: wine
Branch: master
Commit: 800a42b90b7f38b792d8dee3df857c9b71578c19
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=800a42b90b7f38b792d8dee3df857c9b71578c19

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Wed Jun  2 17:04:00 2021 -0500

ws2_32: Use IOCTL_AFD_WINE_FIONREAD.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ws2_32/socket.c     | 27 ++++++---------------------
 dlls/ws2_32/tests/sock.c | 21 +++++++++------------
 2 files changed, 15 insertions(+), 33 deletions(-)

diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 478ae960541..e9df9f579f2 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -3359,28 +3359,13 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
 
     case WS_FIONREAD:
     {
-#if defined(linux)
-        int listening = 0;
-        socklen_t len = sizeof(listening);
-#endif
-        if (out_size != sizeof(WS_u_long) || IS_INTRESOURCE(out_buff))
-        {
-            SetLastError(WSAEFAULT);
-            return SOCKET_ERROR;
-        }
-        if ((fd = get_sock_fd( s, 0, NULL )) == -1) return SOCKET_ERROR;
+        DWORD ret;
 
-#if defined(linux)
-        /* On Linux, FIONREAD on listening socket always fails (see tcp(7)).
-           However, it succeeds on native. */
-        if (!getsockopt( fd, SOL_SOCKET, SO_ACCEPTCONN, &listening, &len ) && listening)
-            (*(WS_u_long *) out_buff) = 0;
-        else
-#endif
-        if (ioctl(fd, FIONREAD, out_buff ) == -1)
-            status = wsaErrno();
-        release_sock_fd( s, fd );
-        break;
+        ret = server_ioctl_sock( s, IOCTL_AFD_WINE_FIONREAD, in_buff, in_size,
+                                 out_buff, out_size, ret_size, overlapped, completion );
+        SetLastError( ret );
+        if (!ret) *ret_size = sizeof(WS_u_long);
+        return ret ? -1 : 0;
     }
 
     case WS_SIOCATMARK:
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index ec138fcf29a..c251f31f382 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -3667,7 +3667,7 @@ static void check_fionread_siocatmark_(int line, SOCKET s, unsigned int normal,
     WSASetLastError(0xdeadbeef);
     ret = WSAIoctl(s, FIONREAD, NULL, 0, &value, sizeof(value), &size, NULL, NULL);
     ok_(__FILE__, line)(!ret, "expected success\n");
-    todo_wine ok_(__FILE__, line)(!WSAGetLastError(), "got error %u\n", WSAGetLastError());
+    ok_(__FILE__, line)(!WSAGetLastError(), "got error %u\n", WSAGetLastError());
     todo_wine_if (todo_normal) ok_(__FILE__, line)(value == normal, "FIONBIO returned %u\n", value);
 
     value = 0xdeadbeef;
@@ -3746,9 +3746,9 @@ static void test_fionread_siocatmark(void)
     overlapped.InternalHigh = 0xdeadbeef;
     ret = WSAIoctl(client, FIONREAD, NULL, 0, &value, sizeof(value), &size, &overlapped, NULL);
     ok(!ret, "expected success\n");
-    todo_wine ok(!WSAGetLastError(), "got error %u\n", WSAGetLastError());
+    ok(!WSAGetLastError(), "got error %u\n", WSAGetLastError());
     ok(!value, "got %u\n", value);
-    todo_wine ok(size == sizeof(value), "got size %u\n", size);
+    ok(size == sizeof(value), "got size %u\n", size);
     ok(!overlapped.Internal, "got status %#x\n", (NTSTATUS)overlapped.Internal);
     ok(!overlapped.InternalHigh, "got size %Iu\n", overlapped.InternalHigh);
 
@@ -3868,17 +3868,14 @@ static void test_fionread_siocatmark(void)
     size = 0xdeadbeef;
     ret = WSAIoctl(server, FIONREAD, NULL, 0, &value, sizeof(value), &size, &overlapped, socket_apc);
     ok(!ret, "expected success\n");
-    todo_wine ok(size == sizeof(value), "got size %u\n", size);
+    ok(size == sizeof(value), "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);
 
     apc_count = 0;
     size = 0xdeadbeef;




More information about the wine-cvs mailing list