Dmitriy Anisimkov : ws2_32: Ignore EINTR poll result code in WS_select.

Alexandre Julliard julliard at winehq.org
Wed Oct 21 13:14:08 CDT 2009


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

Author: Dmitriy Anisimkov <anisimkov at ada-ru.org>
Date:   Tue Oct 20 23:35:00 2009 +0700

ws2_32: Ignore EINTR poll result code in WS_select.

---

 dlls/ws2_32/socket.c |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 35f7b07..7cf4b96 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -2883,6 +2883,8 @@ int WINAPI WS_select(int nfds, WS_fd_set *ws_readfds,
                      const struct WS_timeval* ws_timeout)
 {
     struct pollfd *pollfds;
+    struct timeval tv1, tv2;
+    int torig = 0;
     int count, ret, timeout = -1;
 
     TRACE("read %p, write %p, excp %p timeout %p\n",
@@ -2894,9 +2896,32 @@ int WINAPI WS_select(int nfds, WS_fd_set *ws_readfds,
         return SOCKET_ERROR;
     }
 
-    if (ws_timeout) timeout = (ws_timeout->tv_sec * 1000) + (ws_timeout->tv_usec + 999) / 1000;
+    if (ws_timeout)
+    {
+        torig = (ws_timeout->tv_sec * 1000) + (ws_timeout->tv_usec + 999) / 1000;
+        timeout = torig;
+        gettimeofday( &tv1, 0 );
+    }
+
+    while ((ret = poll( pollfds, count, timeout )) < 0)
+    {
+        if (errno == EINTR)
+        {
+            if (!ws_timeout) continue;
+            gettimeofday( &tv2, 0 );
 
-    ret = poll( pollfds, count, timeout );
+            tv2.tv_sec  -= tv1.tv_sec;
+            tv2.tv_usec -= tv1.tv_usec;
+            if (tv2.tv_usec < 0)
+            {
+                tv2.tv_usec += 1000000;
+                tv2.tv_sec  -= 1;
+            }
+
+            timeout = torig - (tv2.tv_sec * 1000) - (tv2.tv_usec + 999) / 1000;
+            if (timeout <= 0) break;
+        } else break;
+    }
     release_poll_fds( ws_readfds, ws_writefds, ws_exceptfds, pollfds );
 
     if (ret == -1) SetLastError(wsaErrno());




More information about the wine-cvs mailing list