test_channel.vim fails with Win32 CUI Vim.
What the following patch fix is
1. Vim sleep 5 msec even when timeout=0.
2. channel_handle_events() closes channel when there is no input.
3. ":sleep" command does not read channel (I am not sure where is the right
place to call channel_handle_events()).
diff --git a/src/channel.c b/src/channel.c
index aa478f1..84356c9 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -1582,7 +1582,7 @@ channel_wait(channel_T *channel, sock_T fd, int
timeout)
&& 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 */
@@ -1887,11 +1887,7 @@ 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 +1903,11 @@ channel_handle_events(void)
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
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 1321b7f..5b4c6ed 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -8904,6 +8904,9 @@ do_sleep(long msec)
{
ui_delay(msec - done > 1000L ? 1000L : msec - done, TRUE);
ui_breakcheck();
+#ifdef FEAT_CHANNEL
+ channel_handle_events();
+#endif
#ifdef MESSAGE_QUEUE
/* Process the netbeans and clientserver messages that may have been
* received in the call to ui_breakcheck() when the GUI is in use. This
--
Yukihiro Nakadaira - [email protected]
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.