Mercurial > vim
comparison src/os_unix.c @ 8761:f8707ec9efe4 v7.4.1669
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Mar 28 19:16:20 2016 +0200
patch 7.4.1669
Problem: When writing buffer lines to a pipe Vim may block.
Solution: Avoid blocking, write more lines later.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 28 Mar 2016 19:30:05 +0200 |
parents | a35b596cd7ac |
children | 210e767296d9 |
comparison
equal
deleted
inserted
replaced
8760:e43830c12eb2 | 8761:f8707ec9efe4 |
---|---|
5537 # ifdef FEAT_MZSCHEME | 5537 # ifdef FEAT_MZSCHEME |
5538 int mzquantum_used = FALSE; | 5538 int mzquantum_used = FALSE; |
5539 # endif | 5539 # endif |
5540 #endif | 5540 #endif |
5541 #ifndef HAVE_SELECT | 5541 #ifndef HAVE_SELECT |
5542 struct pollfd fds[6 + MAX_OPEN_CHANNELS]; | 5542 /* each channel may use in, out and err */ |
5543 struct pollfd fds[6 + 3 * MAX_OPEN_CHANNELS]; | |
5543 int nfd; | 5544 int nfd; |
5544 # ifdef FEAT_XCLIPBOARD | 5545 # ifdef FEAT_XCLIPBOARD |
5545 int xterm_idx = -1; | 5546 int xterm_idx = -1; |
5546 # endif | 5547 # endif |
5547 # ifdef FEAT_MOUSE_GPM | 5548 # ifdef FEAT_MOUSE_GPM |
5650 | 5651 |
5651 #else /* HAVE_SELECT */ | 5652 #else /* HAVE_SELECT */ |
5652 | 5653 |
5653 struct timeval tv; | 5654 struct timeval tv; |
5654 struct timeval *tvp; | 5655 struct timeval *tvp; |
5655 fd_set rfds, efds; | 5656 fd_set rfds, wfds, efds; |
5656 int maxfd; | 5657 int maxfd; |
5657 long towait = msec; | 5658 long towait = msec; |
5658 | 5659 |
5659 # ifdef FEAT_MZSCHEME | 5660 # ifdef FEAT_MZSCHEME |
5660 mzvim_check_threads(); | 5661 mzvim_check_threads(); |
5683 /* | 5684 /* |
5684 * Select on ready for reading and exceptional condition (end of file). | 5685 * Select on ready for reading and exceptional condition (end of file). |
5685 */ | 5686 */ |
5686 select_eintr: | 5687 select_eintr: |
5687 FD_ZERO(&rfds); | 5688 FD_ZERO(&rfds); |
5689 FD_ZERO(&wfds); | |
5688 FD_ZERO(&efds); | 5690 FD_ZERO(&efds); |
5689 FD_SET(fd, &rfds); | 5691 FD_SET(fd, &rfds); |
5690 # if !defined(__QNX__) && !defined(__CYGWIN32__) | 5692 # if !defined(__QNX__) && !defined(__CYGWIN32__) |
5691 /* For QNX select() always returns 1 if this is set. Why? */ | 5693 /* For QNX select() always returns 1 if this is set. Why? */ |
5692 FD_SET(fd, &efds); | 5694 FD_SET(fd, &efds); |
5723 if (maxfd < xsmp_icefd) | 5725 if (maxfd < xsmp_icefd) |
5724 maxfd = xsmp_icefd; | 5726 maxfd = xsmp_icefd; |
5725 } | 5727 } |
5726 # endif | 5728 # endif |
5727 # ifdef FEAT_JOB_CHANNEL | 5729 # ifdef FEAT_JOB_CHANNEL |
5728 maxfd = channel_select_setup(maxfd, &rfds); | 5730 maxfd = channel_select_setup(maxfd, &rfds, &wfds); |
5729 # endif | 5731 # endif |
5730 | 5732 |
5731 ret = select(maxfd + 1, &rfds, NULL, &efds, tvp); | 5733 ret = select(maxfd + 1, &rfds, &wfds, &efds, tvp); |
5732 result = ret > 0 && FD_ISSET(fd, &rfds); | 5734 result = ret > 0 && FD_ISSET(fd, &rfds); |
5733 if (result) | 5735 if (result) |
5734 --ret; | 5736 --ret; |
5735 if (break_loop != NULL && ret > 0) | 5737 if (break_loop != NULL && ret > 0) |
5736 *break_loop = TRUE; | 5738 *break_loop = TRUE; |
5808 } | 5810 } |
5809 } | 5811 } |
5810 # endif | 5812 # endif |
5811 #ifdef FEAT_JOB_CHANNEL | 5813 #ifdef FEAT_JOB_CHANNEL |
5812 if (ret > 0) | 5814 if (ret > 0) |
5813 ret = channel_select_check(ret, &rfds); | 5815 ret = channel_select_check(ret, &rfds, &wfds); |
5814 #endif | 5816 #endif |
5815 | 5817 |
5816 #endif /* HAVE_SELECT */ | 5818 #endif /* HAVE_SELECT */ |
5817 | 5819 |
5818 #ifdef MAY_LOOP | 5820 #ifdef MAY_LOOP |