Patch 7.4.1293
Problem: Sometimes a channel may hang waiting for a message that was
already discarded. (Ken Takata)
Solution: Store the ID of the message blocking on in the channel.
Files: src/channel.c
*** ../vim-7.4.1292/src/channel.c 2016-02-07 22:21:15.718056931 +0100
--- src/channel.c 2016-02-08 23:21:41.939013575 +0100
***************
*** 116,121 ****
--- 116,123 ----
void (*ch_close_cb)(void); /* callback for when channel is closed */
+ int ch_block_id; /* ID that channel_read_json_block() is
+ waiting for */
char_u *ch_callback; /* function to call when a msg is not handled */
cbq_T ch_cb_head; /* dummy node for pre-request callbacks */
***************
*** 765,779 ****
/*
* Get a message from the JSON queue for channel "ch_idx".
* When "id" is positive it must match the first number in the list.
! * When "id" is zero or negative jut get the first message.
* Return OK when found and return the value in "rettv".
* Return FAIL otherwise.
*/
static int
channel_get_json(int ch_idx, int id, typval_T **rettv)
{
! jsonq_T *head = &channels[ch_idx].ch_json_head;
! jsonq_T *item = head->next;
while (item != head)
{
--- 767,783 ----
/*
* Get a message from the JSON queue for channel "ch_idx".
* When "id" is positive it must match the first number in the list.
! * When "id" is zero or negative jut get the first message. But not the one
! * with id ch_block_id.
* Return OK when found and return the value in "rettv".
* Return FAIL otherwise.
*/
static int
channel_get_json(int ch_idx, int id, typval_T **rettv)
{
! channel_T *channel = &channels[ch_idx];
! jsonq_T *head = &channel->ch_json_head;
! jsonq_T *item = head->next;
while (item != head)
{
***************
*** 781,787 ****
typval_T *tv = &l->lv_first->li_tv;
if ((id > 0 && tv->v_type == VAR_NUMBER && tv->vval.v_number == id)
! || id <= 0)
{
*rettv = item->value;
remove_json_node(item);
--- 785,792 ----
typval_T *tv = &l->lv_first->li_tv;
if ((id > 0 && tv->v_type == VAR_NUMBER && tv->vval.v_number == id)
! || (id <= 0 && (tv->v_type != VAR_NUMBER
! || tv->vval.v_number != channel->ch_block_id)))
{
*rettv = item->value;
remove_json_node(item);
***************
*** 1291,1305 ****
int
channel_read_json_block(int ch_idx, int id, typval_T **rettv)
{
! int more;
for (;;)
{
more = channel_parse_json(ch_idx);
/* search for messsage "id" */
if (channel_get_json(ch_idx, id, rettv) == OK)
return OK;
if (!more)
{
--- 1296,1315 ----
int
channel_read_json_block(int ch_idx, int id, typval_T **rettv)
{
! int more;
! channel_T *channel = &channels[ch_idx];
+ channel->ch_block_id = id;
for (;;)
{
more = channel_parse_json(ch_idx);
/* search for messsage "id" */
if (channel_get_json(ch_idx, id, rettv) == OK)
+ {
+ channel->ch_block_id = 0;
return OK;
+ }
if (!more)
{
***************
*** 1309,1321 ****
continue;
/* Wait for up to the channel timeout. */
! if (channels[ch_idx].ch_fd < 0
! || channel_wait(channels[ch_idx].ch_fd,
! channels[ch_idx].ch_timeout) == FAIL)
break;
channel_read(ch_idx);
}
}
return FAIL;
}
--- 1319,1331 ----
continue;
/* Wait for up to the channel timeout. */
! if (channel->ch_fd < 0 || channel_wait(channel->ch_fd,
! channel->ch_timeout) == FAIL)
break;
channel_read(ch_idx);
}
}
+ channel->ch_block_id = 0;
return FAIL;
}
*** ../vim-7.4.1292/src/version.c 2016-02-08 22:57:19.618344973 +0100
--- src/version.c 2016-02-08 23:19:49.596191304 +0100
***************
*** 749,750 ****
--- 749,752 ----
{ /* Add new patch number below this line */
+ /**/
+ 1293,
/**/
--
hundred-and-one symptoms of being an internet addict:
193. You ask your girlfriend to drive home so you can sit back with
your PDA and download the information to your laptop
/// 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.