Zebediah Figura : server: Report AFD_POLL_CONNECT_ERR if a previous connection attempt failed.

Alexandre Julliard julliard at winehq.org
Tue Jul 6 18:09:35 CDT 2021


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

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Mon Jul  5 19:14:19 2021 -0500

server: Report AFD_POLL_CONNECT_ERR if a previous connection attempt failed.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51331
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51366
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ws2_32/tests/afd.c  | 51 ++++++++++++++++++++----------------------------
 dlls/ws2_32/tests/sock.c | 16 +++++++--------
 server/sock.c            |  8 ++++++++
 3 files changed, 37 insertions(+), 38 deletions(-)

diff --git a/dlls/ws2_32/tests/afd.c b/dlls/ws2_32/tests/afd.c
index 9afb8e86dc9..4b8796157aa 100644
--- a/dlls/ws2_32/tests/afd.c
+++ b/dlls/ws2_32/tests/afd.c
@@ -464,30 +464,24 @@ static void test_poll(void)
         memset(out_params, 0xcc, sizeof(out_buffer));
         ret = NtDeviceIoControlFile((HANDLE)client, event, NULL, NULL, &io,
                 IOCTL_AFD_POLL, in_params, params_size, out_params, params_size);
-        todo_wine
-        {
-            ok(!ret, "got %#x\n", ret);
-            ok(!io.Status, "got %#x\n", io.Status);
-            ok(io.Information == offsetof(struct afd_poll_params, sockets[1]), "got %#Ix\n", io.Information);
-            ok(out_params->count == 1, "got count %u\n", out_params->count);
-            ok(out_params->sockets[0].socket == client, "got socket %#Ix\n", out_params->sockets[0].socket);
-            ok(out_params->sockets[0].flags == AFD_POLL_CONNECT_ERR, "got flags %#x\n", out_params->sockets[0].flags);
-            ok(out_params->sockets[0].status == STATUS_CONNECTION_REFUSED, "got status %#x\n", out_params->sockets[0].status);
-        }
+        ok(!ret, "got %#x\n", ret);
+        ok(!io.Status, "got %#x\n", io.Status);
+        ok(io.Information == offsetof(struct afd_poll_params, sockets[1]), "got %#Ix\n", io.Information);
+        ok(out_params->count == 1, "got count %u\n", out_params->count);
+        ok(out_params->sockets[0].socket == client, "got socket %#Ix\n", out_params->sockets[0].socket);
+        ok(out_params->sockets[0].flags == AFD_POLL_CONNECT_ERR, "got flags %#x\n", out_params->sockets[0].flags);
+        ok(out_params->sockets[0].status == STATUS_CONNECTION_REFUSED, "got status %#x\n", out_params->sockets[0].status);
 
         memset(out_params, 0xcc, sizeof(out_buffer));
         ret = NtDeviceIoControlFile((HANDLE)client, event, NULL, NULL, &io,
                 IOCTL_AFD_POLL, in_params, params_size, out_params, params_size);
-        todo_wine
-        {
-            ok(!ret, "got %#x\n", ret);
-            ok(!io.Status, "got %#x\n", io.Status);
-            ok(io.Information == offsetof(struct afd_poll_params, sockets[1]), "got %#Ix\n", io.Information);
-            ok(out_params->count == 1, "got count %u\n", out_params->count);
-            ok(out_params->sockets[0].socket == client, "got socket %#Ix\n", out_params->sockets[0].socket);
-            ok(out_params->sockets[0].flags == AFD_POLL_CONNECT_ERR, "got flags %#x\n", out_params->sockets[0].flags);
-            ok(out_params->sockets[0].status == STATUS_CONNECTION_REFUSED, "got status %#x\n", out_params->sockets[0].status);
-        }
+        ok(!ret, "got %#x\n", ret);
+        ok(!io.Status, "got %#x\n", io.Status);
+        ok(io.Information == offsetof(struct afd_poll_params, sockets[1]), "got %#Ix\n", io.Information);
+        ok(out_params->count == 1, "got count %u\n", out_params->count);
+        ok(out_params->sockets[0].socket == client, "got socket %#Ix\n", out_params->sockets[0].socket);
+        ok(out_params->sockets[0].flags == AFD_POLL_CONNECT_ERR, "got flags %#x\n", out_params->sockets[0].flags);
+        ok(out_params->sockets[0].status == STATUS_CONNECTION_REFUSED, "got status %#x\n", out_params->sockets[0].status);
 
         ret = connect(client, (struct sockaddr *)&addr, sizeof(addr));
         ok(ret == -1, "got %d\n", ret);
@@ -514,16 +508,13 @@ static void test_poll(void)
         memset(out_params, 0xcc, sizeof(out_buffer));
         ret = NtDeviceIoControlFile((HANDLE)client, event, NULL, NULL, &io,
                 IOCTL_AFD_POLL, in_params, params_size, out_params, params_size);
-        todo_wine
-        {
-            ok(!ret, "got %#x\n", ret);
-            ok(!io.Status, "got %#x\n", io.Status);
-            ok(io.Information == offsetof(struct afd_poll_params, sockets[1]), "got %#Ix\n", io.Information);
-            ok(out_params->count == 1, "got count %u\n", out_params->count);
-            ok(out_params->sockets[0].socket == client, "got socket %#Ix\n", out_params->sockets[0].socket);
-            ok(out_params->sockets[0].flags == AFD_POLL_CONNECT_ERR, "got flags %#x\n", out_params->sockets[0].flags);
-            ok(out_params->sockets[0].status == STATUS_CONNECTION_REFUSED, "got status %#x\n", out_params->sockets[0].status);
-        }
+        ok(!ret, "got %#x\n", ret);
+        ok(!io.Status, "got %#x\n", io.Status);
+        ok(io.Information == offsetof(struct afd_poll_params, sockets[1]), "got %#Ix\n", io.Information);
+        ok(out_params->count == 1, "got count %u\n", out_params->count);
+        ok(out_params->sockets[0].socket == client, "got socket %#Ix\n", out_params->sockets[0].socket);
+        ok(out_params->sockets[0].flags == AFD_POLL_CONNECT_ERR, "got flags %#x\n", out_params->sockets[0].flags);
+        ok(out_params->sockets[0].status == STATUS_CONNECTION_REFUSED, "got status %#x\n", out_params->sockets[0].status);
 
         closesocket(client);
     }
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index df5a69b4564..9e7cd3a1d39 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -3263,8 +3263,8 @@ static void test_select(void)
         FD_SET(fdWrite, &exceptfds);
         select_timeout.tv_sec = 10;
         ret = select(0, &readfds, &writefds, &exceptfds, &select_timeout);
-        todo_wine ok(ret == 1, "expected 1, got %d\n", ret);
-        todo_wine ok(FD_ISSET(fdWrite, &exceptfds), "fdWrite socket is not in the set\n");
+        ok(ret == 1, "expected 1, got %d\n", ret);
+        ok(FD_ISSET(fdWrite, &exceptfds), "fdWrite socket is not in the set\n");
         ok(select_timeout.tv_usec == 250000, "select timeout should not have changed\n");
 
         len = sizeof(id);
@@ -3285,8 +3285,8 @@ static void test_select(void)
         FD_SET(fdWrite, &exceptfds);
         select_timeout.tv_sec = 10;
         ret = select(0, &readfds, &writefds, &exceptfds, &select_timeout);
-        todo_wine ok(ret == 1, "got %d\n", ret);
-        todo_wine ok(FD_ISSET(fdWrite, &exceptfds), "fdWrite socket is not in the set\n");
+        ok(ret == 1, "got %d\n", ret);
+        ok(FD_ISSET(fdWrite, &exceptfds), "fdWrite socket is not in the set\n");
 
         /* Calling connect() doesn't reset the socket error, but a successful
          * connection does. This is kind of tricky to test, because while
@@ -3315,8 +3315,8 @@ static void test_select(void)
         FD_SET(fdWrite, &exceptfds);
         select_timeout.tv_sec = 10;
         ret = select(0, &readfds, &writefds, &exceptfds, &select_timeout);
-        todo_wine ok(ret == 1, "got %d\n", ret);
-        todo_wine ok(FD_ISSET(fdWrite, &exceptfds), "fdWrite socket is not in the set\n");
+        ok(ret == 1, "got %d\n", ret);
+        ok(FD_ISSET(fdWrite, &exceptfds), "fdWrite socket is not in the set\n");
 
         len = sizeof(address);
         ret = getsockname(fdListen, (struct sockaddr *)&address, &len);
@@ -3362,8 +3362,8 @@ static void test_select(void)
         FD_SET(fdWrite, &exceptfds);
         select_timeout.tv_sec = 0;
         ret = select(0, &readfds, &writefds, &exceptfds, &select_timeout);
-        todo_wine ok(ret == 1, "expected 1, got %d\n", ret);
-        todo_wine ok(FD_ISSET(fdWrite, &exceptfds), "fdWrite socket is not in the set\n");
+        ok(ret == 1, "expected 1, got %d\n", ret);
+        ok(FD_ISSET(fdWrite, &exceptfds), "fdWrite socket is not in the set\n");
 
         len = sizeof(id);
         id = 0xdeadbeef;
diff --git a/server/sock.c b/server/sock.c
index b1cf628abae..58e9cf4302a 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -2820,6 +2820,14 @@ static int poll_socket( struct sock *poll_sock, struct async *async, timeout_t t
             output[i].flags = flags;
             output[i].status = sock_get_ntstatus( sock_error( sock->fd ) );
         }
+
+        /* FIXME: do other error conditions deserve a similar treatment? */
+        if (sock->state != SOCK_CONNECTING && sock->errors[AFD_POLL_BIT_CONNECT_ERR] && (mask & AFD_POLL_CONNECT_ERR))
+        {
+            req->iosb->status = STATUS_SUCCESS;
+            output[i].flags |= AFD_POLL_CONNECT_ERR;
+            output[i].status = sock_get_ntstatus( sock->errors[AFD_POLL_BIT_CONNECT_ERR] );
+        }
     }
 
     if (req->iosb->status != STATUS_PENDING)




More information about the wine-cvs mailing list