Kay Zheng wrote:

> I did some research on the channel code, and if I read it right,
> there's an issue in channel_fill(...).
> 
> AFAIK, a channel in JSON mode works like this:
> 
> 1. When a network message arrives, it tries to parse a complete JSON object.
> 2. If there were a complete JSON object, it saves the object and tries
> to call the callbacks. Otherwise, it may call channel_fill(...) to
> fetch more data.
> 3. If channel_fill(...) cannot provide enough data, it puts the
> partial message back into the channel buffers via channel_save(...),
> for the next parsing operation to start over.
> 
> The problem is, channel_fill(...) may drop part of the buffered
> message according to reader->js_used, thus messing up the partial
> message saved in step 3.
> 
> I managed to reproduce the problem with these code:
> 
> https://gist.github.com/l04m33/d1c910f854d19520101dc1bc332277eb
> 
> Run server.py first, then source client.vim in Vim. The second JSON
> message will NOT trigger the channel callback.
> 
> I came up with a simple patch, by always preserving the "used parts"
> of the messages. I'm using commit
> 544d3bc9f0e494cb712a33b61558b8e8e12b1e0b from the GitHub repo.

I'm glad you have been able to figure out this problem.
I thought there was a test for a split message, but apparently it
doesn't catch this situation.  I managed to add a test that does.

I also notice that when the message receives in parts, the 100 msec
timeout is not reset.  I'll fix that too.

-- 
"I know that there are people who don't love their fellow man,
and I hate those people!" - Tom Lehrer

 /// Bram Moolenaar -- b...@moolenaar.net -- 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_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to