]> granicus.if.org Git - vim/commitdiff
patch 7.4.1667 v7.4.1667
authorBram Moolenaar <Bram@vim.org>
Mon, 28 Mar 2016 12:20:41 +0000 (14:20 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 28 Mar 2016 12:20:41 +0000 (14:20 +0200)
Problem:    Win32: waiting on a pipe with fixed sleep time.
Solution:   Start with a short delay and increase it when looping.

src/channel.c
src/version.c

index a506598d7d1dd23456f16937b4f9e6a5f45a882d..70c44135358462906d282190a5b7eb29f41f80f2 100644 (file)
@@ -2371,8 +2371,9 @@ channel_wait(channel_T *channel, sock_T fd, int timeout)
     if (fd != channel->CH_SOCK_FD)
     {
        DWORD   nread;
-       int     diff;
+       int     sleep_time;
        DWORD   deadline = GetTickCount() + timeout;
+       int     delay = 1;
 
        /* reading from a pipe, not a socket */
        while (TRUE)
@@ -2380,12 +2381,17 @@ channel_wait(channel_T *channel, sock_T fd, int timeout)
            if (PeekNamedPipe((HANDLE)fd, NULL, 0, NULL, &nread, NULL)
                                                                 && nread > 0)
                return OK;
-           diff = deadline - GetTickCount();
-           if (diff <= 0)
+           sleep_time = deadline - GetTickCount();
+           if (sleep_time <= 0)
                break;
-           /* Wait for 5 msec.
-            * TODO: increase the sleep time when looping more often */
-           Sleep(5);
+           /* Wait for a little while.  Very short at first, up to 10 msec
+            * after looping a few times. */
+           if (sleep_time > delay)
+               sleep_time = delay;
+           Sleep(sleep_time);
+           delay = delay * 2;
+           if (delay > 10)
+               delay = 10;
        }
     }
     else
index 5a55707fa352ab249a8b79308785483d3d21a2ff..ae5d4b021f8db24064e30e27b7f6206568594c45 100644 (file)
@@ -748,6 +748,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1667,
 /**/
     1666,
 /**/