comparison src/channel.c @ 8172:db5c79d93eee v7.4.1379

commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 21 17:20:55 2016 +0100 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)
author Christian Brabandt <cb@256bit.org>
date Sun, 21 Feb 2016 17:30:05 +0100
parents 973686665238
children f2286ff0c102
comparison
equal deleted inserted replaced
8171:944260338639 8172:db5c79d93eee
1580 { 1580 {
1581 if (PeekNamedPipe((HANDLE)fd, NULL, 0, NULL, &nread, NULL) 1581 if (PeekNamedPipe((HANDLE)fd, NULL, 0, NULL, &nread, NULL)
1582 && nread > 0) 1582 && nread > 0)
1583 return OK; 1583 return OK;
1584 diff = deadline - GetTickCount(); 1584 diff = deadline - GetTickCount();
1585 if (diff < 0) 1585 if (diff <= 0)
1586 break; 1586 break;
1587 /* Wait for 5 msec. 1587 /* Wait for 5 msec.
1588 * TODO: increase the sleep time when looping more often */ 1588 * TODO: increase the sleep time when looping more often */
1589 Sleep(5); 1589 Sleep(5);
1590 } 1590 }
1879 return channel; 1879 return channel;
1880 } 1880 }
1881 } 1881 }
1882 return NULL; 1882 return NULL;
1883 } 1883 }
1884 1884 # endif
1885
1886 # if defined(WIN32) || defined(PROTO)
1887 /*
1888 * Check the channels for anything that is ready to be read.
1889 * The data is put in the read queue.
1890 */
1885 void 1891 void
1886 channel_handle_events(void) 1892 channel_handle_events(void)
1887 { 1893 {
1888 channel_T *channel; 1894 channel_T *channel;
1889 int part; 1895 int part;
1890 static int loop = 0; 1896 sock_T fd;
1891
1892 /* Skip heavily polling */
1893 if (loop++ % 2)
1894 return;
1895 1897
1896 for (channel = first_channel; channel != NULL; channel = channel->ch_next) 1898 for (channel = first_channel; channel != NULL; channel = channel->ch_next)
1897 { 1899 {
1898 # ifdef FEAT_GUI_W32 1900 # ifdef FEAT_GUI_W32
1899 /* only check the pipes */ 1901 /* only check the pipes */
1905 # else 1907 # else
1906 /* only check the socket */ 1908 /* only check the socket */
1907 part = PART_SOCK; 1909 part = PART_SOCK;
1908 # endif 1910 # endif
1909 # endif 1911 # endif
1910 channel_read(channel, part, "channel_handle_events"); 1912 {
1913 fd = channel->ch_part[part].ch_fd;
1914 if (fd != INVALID_FD && channel_wait(channel, fd, 0) == OK)
1915 channel_read(channel, part, "channel_handle_events");
1916 }
1911 } 1917 }
1912 } 1918 }
1913 # endif 1919 # endif
1914 1920
1915 /* 1921 /*