patch 7.4.1379
Problem: Channel test fails on Win32 console.
Solution: Don't sleep when timeout is zero. Call channel_wait() before
channel_read(). Channels are not polled during ":sleep". (Yukihiro
Nakadaira)
diff --git a/src/channel.c b/src/channel.c
index aa478f1..d02f019 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -1582,7 +1582,7 @@
&& nread > 0)
return OK;
diff = deadline - GetTickCount();
- if (diff < 0)
+ if (diff <= 0)
break;
/* Wait for 5 msec.
* TODO: increase the sleep time when looping more often */
@@ -1881,17 +1881,19 @@
}
return NULL;
}
+# endif
+# if defined(WIN32) || defined(PROTO)
+/*
+ * Check the channels for anything that is ready to be read.
+ * The data is put in the read queue.
+ */
void
channel_handle_events(void)
{
channel_T *channel;
int part;
- static int loop = 0;
-
- /* Skip heavily polling */
- if (loop++ % 2)
- return;
+ sock_T fd;
for (channel = first_channel; channel != NULL; channel = channel->ch_next)
{
@@ -1907,7 +1909,11 @@
part = PART_SOCK;
# endif
# endif
- channel_read(channel, part, "channel_handle_events");
+ {
+ fd = channel->ch_part[part].ch_fd;
+ if (fd != INVALID_FD && channel_wait(channel, fd, 0) == OK)
+ channel_read(channel, part, "channel_handle_events");
+ }
}
}
# endif