Bruno Jesus : ws2_32: Fix handling of POLLHUP in WSAPoll.

Alexandre Julliard julliard at winehq.org
Wed Sep 14 10:28:51 CDT 2016


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

Author: Bruno Jesus <00cpxxx at gmail.com>
Date:   Tue Sep 13 15:38:15 2016 -0300

ws2_32: Fix handling of POLLHUP in WSAPoll.

Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

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

diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 2d54013..9d0b60e 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -5378,7 +5378,20 @@ int WINAPI WSAPoll(WSAPOLLFD *wfds, ULONG count, int timeout)
         if (ufds[i].fd != -1)
         {
             release_sock_fd(wfds[i].fd, ufds[i].fd);
-            wfds[i].revents = convert_poll_u2w(ufds[i].revents);
+            if (ufds[i].revents & POLLHUP)
+            {
+                /* Check if the socket still exists */
+                int fd = get_sock_fd(wfds[i].fd, 0, NULL);
+                if (fd != -1)
+                {
+                    wfds[i].revents = WS_POLLHUP;
+                    release_sock_fd(wfds[i].fd, fd);
+                }
+                else
+                    wfds[i].revents = WS_POLLNVAL;
+            }
+            else
+                wfds[i].revents = convert_poll_u2w(ufds[i].revents);
         }
         else
             wfds[i].revents = WS_POLLNVAL;
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index d216542..320f820 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -6672,7 +6672,6 @@ static void test_WSAPoll(void)
     POLL_SET(fdWrite, POLLIN);
     ret = pWSAPoll(fds, ix, poll_timeout);
     ok(ret == 1, "expected 1, got %d\n", ret);
-todo_wine
     ok(POLL_ISSET(fdWrite, POLLHUP), "fdWrite socket events incorrect\n");
     ret = recv(fdWrite, tmp_buf, sizeof(tmp_buf), 0);
     ok(ret == 0, "expected 0, got %d\n", ret);
@@ -6737,7 +6736,6 @@ todo_wine
     POLL_SET(fdWrite, POLLIN);
     ret = pWSAPoll(fds, ix, poll_timeout);
     ok(ret == 1, "expected 1, got %d\n", ret);
-todo_wine
     ok(POLL_ISSET(fdWrite, POLLNVAL), "fdWrite socket events incorrect\n");
     WaitForSingleObject (thread_handle, 1000);
     closesocket(fdRead);




More information about the wine-cvs mailing list