Damjan Jovanovic : wineserver: Avoid spurious FD_WRITE on repeated calls to WSAEventSelect().

Alexandre Julliard julliard at winehq.org
Fri Dec 20 14:07:24 CST 2019


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

Author: Damjan Jovanovic <damjan.jov at gmail.com>
Date:   Fri Dec 20 04:16:05 2019 +0200

wineserver: Avoid spurious FD_WRITE on repeated calls to WSAEventSelect().

Repeated calls to WSAEventSelect() with FD_WRITE deliver
spurious FD_WRITE events, as the flag isn't held, resulting
in us unnecessarily polling the socket for writability,
despite the fact FD_WRITE should only be delivered (1) initially
on socket creation, and (2) after send[to]() fails with
EWOULDBLOCK and buffer space becomes available.

Signed-off-by: Damjan Jovanovic <damjan.jov at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ws2_32/tests/sock.c | 5 ++---
 server/sock.c            | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 60c5dfc63f..fa9d081185 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -3053,9 +3053,8 @@ static void test_WSAEnumNetworkEvents(void)
                 }
                 else
                 {
-                    todo_wine_if (i != 0) /* Remove when fixed */
-                        ok (net_events.lNetworkEvents == 0, "Test[%d]: expected 0, got %d\n",
-                            i, net_events.lNetworkEvents);
+                    ok (net_events.lNetworkEvents == 0, "Test[%d]: expected 0, got %d\n",
+                        i, net_events.lNetworkEvents);
                 }
                 for (k = 0; k < FD_MAX_EVENTS; k++)
                 {
diff --git a/server/sock.c b/server/sock.c
index 1a53ce4b09..29542cd01f 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -1228,7 +1228,7 @@ DECL_HANDLER(set_socket_event)
                                                 FILE_WRITE_ATTRIBUTES, &sock_ops))) return;
     old_event = sock->event;
     sock->mask    = req->mask;
-    sock->hmask   &= ~req->mask; /* re-enable held events */
+    sock->hmask   &= (FD_WRITE | ~req->mask); /* re-enable held events */
     sock->event   = NULL;
     sock->window  = req->window;
     sock->message = req->msg;




More information about the wine-cvs mailing list