Pontus Leitzler wrote:
> Just to summarize:
> - channel_read() reads 63 bytes and calls channel_save()
> - channel_save() saves those to a new node->rq_buffer at the end of channel=
> head
>
> To convert it to JSON someone must call channel_parse_json(), and it can be=
> either from channel_read_json_block() or may_invoke_callback().
> My logs shows that it is via may_invoke_callback() until it hangs.
>
> - may_invoke_callback() is called from channel_parse_messages()
> - channel_parse_messages() is called from parse_queued_messages()
> - parse_queued_messages() is called from inchar_loop()
>
> But, since channel_parse_json() haven't been called yet for the latest mess=
> age, inchar_loop() will allow a wait_func()-call with wait_time =3D=3D -1 (=
> that leads to RealWaitForChar() NULL).
>
> To avoid it, inchar_loop() calls channel_any_readahead(), but it will retur=
> n FALSE since the messages haven't been parsed to JSON yet and it only chec=
> ks the JSON queue in JSON mode.
>
> So I guess the solution to this is to either let channel_any_readahead() ca=
> ll channel_peek() in JSON mode as well, or add a call to channel_parse_json=
> () somewhere to ensure that the incoming message has been parsed so that ch=
> annel_any_readahead() returns TRUE in JSON-mode (?).
>
> I'm sorry if my explanation is messy, it's probably a combination of me not=
> being familiar with the code base as well as not being native English :)
Thanks for the digging and explanation. channel_has_readahead() is
called in a few places, checking if there is something ready to read.
But it doesn't use any received text on a JSON channel if it hasn't been
parsed yet. It looks like calling channel_parse_json() in
channel_has_readahead() would be the right thing to do.
Please try if this patch fixes your problem:
--- prev/src/channel.c 2019-06-24 00:43:31.463691826 +0200
+++ channel.c 2019-06-28 04:41:25.767304149 +0200
@@ -2850,10 +2850,13 @@
if (ch_mode == MODE_JSON || ch_mode == MODE_JS)
{
- jsonq_T *head = &channel->ch_part[part].ch_json_head;
- jsonq_T *item = head->jq_next;
+ jsonq_T *head;
- return item != NULL;
+ // Parse json from readahead before checking the queue.
+ channel_parse_json(channel, part);
+
+ head = &channel->ch_part[part].ch_json_head;
+ return head->jq_next != NULL;
}
return channel_peek(channel, part) != NULL;
}
--
The greatest lies of all time:
(1) The check is in the mail.
(2) We have a really challenging assignment for you.
(3) I love you.
(4) All bugs have been fixed.
(5) This won't hurt a bit.
(6) Honey, I just need to debug this program and be home in 5 minutes.
(7) I have just sent you an e-mail about that.
(8) Of course I'll respect you in the morning.
(9) I'm from the government, and I'm here to help you.
/// 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/201906280258.x5S2w16o028398%40masaka.moolenaar.net.
For more options, visit https://groups.google.com/d/optout.