# HG changeset patch # User Christian Brabandt # Date 1459168205 -7200 # Node ID 4fb37555e814fe97c07f38f33a11aec66c17932f # Parent 72dbac4224b87e675f78f85fab040ae8d465bd7d commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe Author: Bram Moolenaar Date: Mon Mar 28 14:20:41 2016 +0200 patch 7.4.1667 Problem: Win32: waiting on a pipe with fixed sleep time. Solution: Start with a short delay and increase it when looping. diff --git a/src/channel.c b/src/channel.c --- a/src/channel.c +++ b/src/channel.c @@ -2371,8 +2371,9 @@ channel_wait(channel_T *channel, sock_T 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 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 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -749,6 +749,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1667, +/**/ 1666, /**/ 1665,