Patch 7.4.2297
Problem: When starting a job that reads from a buffer and reaching the end,
the job hangs.
Solution: Close the pipe or socket when all lines were read.
Files: src/channel.c, src/testdir/test_channel.vim
*** ../vim-7.4.2296/src/channel.c 2016-08-29 22:48:12.113106491 +0200
--- src/channel.c 2016-09-01 14:33:06.551900688 +0200
***************
*** 1424,1434 ****
ch_logn(channel, "written %d lines to channel", written);
in_part->ch_buf_top = lnum;
! if (lnum > buf->b_ml.ml_line_count)
{
/* Writing is done, no longer need the buffer. */
in_part->ch_bufref.br_buf = NULL;
ch_log(channel, "Finished writing all lines to channel");
}
else
ch_logn(channel, "Still %d more lines to write",
--- 1424,1437 ----
ch_logn(channel, "written %d lines to channel", written);
in_part->ch_buf_top = lnum;
! if (lnum > buf->b_ml.ml_line_count || lnum > in_part->ch_buf_bot)
{
/* Writing is done, no longer need the buffer. */
in_part->ch_bufref.br_buf = NULL;
ch_log(channel, "Finished writing all lines to channel");
+
+ /* Close the pipe/socket, so that the other side gets EOF. */
+ may_close_part(&channel->CH_IN_FD);
}
else
ch_logn(channel, "Still %d more lines to write",
*** ../vim-7.4.2296/src/testdir/test_channel.vim 2016-08-28
19:26:39.624111889 +0200
--- src/testdir/test_channel.vim 2016-09-01 14:21:31.461858740 +0200
***************
*** 792,797 ****
--- 792,837 ----
call Run_test_pipe_from_buffer(0)
endfunc
+ func Run_pipe_through_sort(all)
+ if !executable('sort') || !has('job')
+ return
+ endif
+ split sortin
+ call setline(1, ['ccc', 'aaa', 'ddd', 'bbb', 'eee'])
+ let options = {'in_io': 'buffer', 'in_name': 'sortin',
+ \ 'out_io': 'buffer', 'out_name': 'sortout'}
+ if !a:all
+ let options.in_top = 2
+ let options.in_bot = 4
+ endif
+ let g:job = job_start('sort', options)
+ call assert_equal("run", job_status(g:job))
+ call WaitFor('job_status(g:job) == "dead"')
+ call assert_equal("dead", job_status(g:job))
+ sp sortout
+ call assert_equal('Reading from channel output...', getline(1))
+ if a:all
+ call assert_equal(['aaa', 'bbb', 'ccc', 'ddd', 'eee'], getline(2, 6))
+ else
+ call assert_equal(['aaa', 'bbb', 'ddd'], getline(2, 4))
+ endif
+
+ call job_stop(g:job)
+ unlet g:job
+ bwipe! sortin
+ bwipe! sortout
+ endfunc
+
+ func Test_pipe_through_sort_all()
+ call ch_log('Test_pipe_through_sort_all()')
+ call Run_pipe_through_sort(1)
+ endfunc
+
+ func Test_pipe_through_sort_some()
+ call ch_log('Test_pipe_through_sort_some()')
+ call Run_pipe_through_sort(0)
+ endfunc
+
func Test_pipe_to_nameless_buffer()
if !has('job')
return
*** ../vim-7.4.2296/src/version.c 2016-08-31 20:33:22.755268342 +0200
--- src/version.c 2016-09-01 14:34:30.447179210 +0200
***************
*** 765,766 ****
--- 765,768 ----
{ /* Add new patch number below this line */
+ /**/
+ 2297,
/**/
--
hundred-and-one symptoms of being an internet addict:
123. You ask the car dealer to install an extra cigarette lighter
on your new car to power your notebook.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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.