Ken Takata wrote:
> I found another problem with channel on Win32 GUI.
> When executing the following line in test_channel.vim, Vim sometimes hangs up:
>
> call assert_equal('ok', ch_sendexpr(handle, 'make change'))
>
> When test_channnel.vim receives 'make change', it send two responses
> '["ex","call append(\\"$\\",\\"added1\\")"]["ex","call
> append(\\"$\\",\\"added2\\")"]'
> and [id, "ok"]. And when Vim receives these responses as two separated
> responses, the problem occurs.
>
>
> 1291 int
> 1292 channel_read_json_block(int ch_idx, int id, typval_T **rettv)
> 1293 {
> 1294 int more;
> 1295
> 1296 for (;;)
> 1297 {
> 1298 more = channel_parse_json(ch_idx);
> 1299
> 1300 /* search for messsage "id" */
> 1301 if (channel_get_json(ch_idx, id, rettv) == OK)
> 1302 return OK;
> 1303
> 1304 if (!more)
> 1305 {
> 1306 /* Handle any other messages in the queue. If done some more
> 1307 * messages may have arrived. */
> 1308 if (channel_parse_messages())
> 1309 continue;
> 1310
> 1311 /* Wait for up to the channel timeout. */
> 1312 if (channels[ch_idx].ch_fd < 0
> 1313 || channel_wait(channels[ch_idx].ch_fd,
> 1314 channels[ch_idx].ch_timeout) ==
> FAIL)
> 1315 break;
> 1316 channel_read(ch_idx);
> 1317 }
> 1318 }
> 1319 return FAIL;
> 1320 }
>
> In L1301, channel_get_json() waits [id, "ok"] but it's not found when the
> responses are separated because the only two ["ex", *] responses are
> available.
> In L1308, channel_parse_messages() calls channel_get_json(), and then it
> receives [id, "ok"] but the response will be thrown away(?).
> Next time in L1301, channel_get_json() cannot find [id, "ok"], so the function
> channel_read_json_block() will not return.
>
> Attached patch seems to fix this, but I'm not sure this is a right solution.
Thanks for figuring out what's wrong. I already changed this code
twice, apparently we are trying to find a simple solution while there
isn't one. Best seems to me that when we are blocked waiting on a
message we should store that ID in the channel and never return it when
looking for any next message.
I'll make a patch, please verify it works after that.
--
hundred-and-one symptoms of being an internet addict:
192. Your boss asks you to "go fer" coffee and you come up with 235 FTP sites.
/// 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.