Matteo Landi wrote:

> On 08/22, Bram Moolenaar wrote:
> >
> >> ch_sendraw seems to fail when sending large chunks of data to a job
> >> started in non-blocking mode.  Is this expected?
> >>
> >> Steps to reproduce:
> >>
> >> - Copy the following into a file, and source it from vim
> >>
> >> let args = ['cat']
> >> let opts = {
> >>         \ 'noblock': 1
> >>         \}
> >>
> >> let job = job_start(args, opts)
> >> let data = repeat('X', 65537)
> >>
> >> call ch_sendraw(job, data)
> >> call ch_close_in(job)
> >>
> >> Expected behavior:
> >>
> >> - Nothing much (i.e. no errors)
> >>
> >> Actual bevarior:
> >>
> >> - E630: channel_write_input(): write while not connected
> >>
> >> If on the other hand, I initialized data with 65536 bytes instead of
> >> 65537, then no error would be thrown.
> >
> >You are using "noblock", which means the write may happen a bit later,
> >but then you use ch_close_in(), closing the channel before all the
> >writes are done.  If you put a sleep there it works.
> 
> Oh, I thought ch_close_in() would wait for any pending write to 
> complete, but I guess that _special mode_ on `:help channel-close-in` 
> did refer to non blocking channels in the end, didn't it?!  My bad!
> 
> Then the next question is, how could I wait for any pending write 
> operation to complete before calling ch_close_in()?  Should I include a 
> EOF in the last message, instead of calling ch_close_in()?

I don't think we have a mechanism for that.  There are callbacks for
reading from input and error, but not for writing.  I suppose it would
be possible to add an in_cb function, called after the write buffer is
empty.  Or just after every finished write.

-- 
Common sense is what tells you that the world is flat.

 /// 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201908221924.x7MJO3vc026795%40masaka.moolenaar.net.

Raspunde prin e-mail lui