Skip to content

Commit 09c5690

Browse files
committed
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Problem: Not parsing messages recursively breaks the govim plugin. Solution: When called recursively do handle messages but do not close channels.
1 parent 599c89c commit 09c5690

2 files changed

Lines changed: 34 additions & 30 deletions

File tree

src/channel.c

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4428,16 +4428,14 @@ channel_parse_messages(void)
44284428
int ret = FALSE;
44294429
int r;
44304430
ch_part_T part = PART_SOCK;
4431-
static int recursive = FALSE;
4431+
static int recursive = 0;
44324432
#ifdef ELAPSED_FUNC
44334433
elapsed_T start_tv;
44344434
#endif
44354435

44364436
// The code below may invoke callbacks, which might call us back.
4437-
// That doesn't work well, just return without doing anything.
4438-
if (recursive)
4439-
return FALSE;
4440-
recursive = TRUE;
4437+
// In a recursive call channels will not be closed.
4438+
++recursive;
44414439
++safe_to_invoke_callback;
44424440

44434441
#ifdef ELAPSED_FUNC
@@ -4454,33 +4452,37 @@ channel_parse_messages(void)
44544452
}
44554453
while (channel != NULL)
44564454
{
4457-
if (channel_can_close(channel))
4458-
{
4459-
channel->ch_to_be_closed = (1U << PART_COUNT);
4460-
channel_close_now(channel);
4461-
// channel may have been freed, start over
4462-
channel = first_channel;
4463-
continue;
4464-
}
4465-
if (channel->ch_to_be_freed || channel->ch_killing)
4455+
if (recursive == 1)
44664456
{
4467-
channel_free_contents(channel);
4468-
if (channel->ch_job != NULL)
4469-
channel->ch_job->jv_channel = NULL;
4457+
if (channel_can_close(channel))
4458+
{
4459+
channel->ch_to_be_closed = (1U << PART_COUNT);
4460+
channel_close_now(channel);
4461+
// channel may have been freed, start over
4462+
channel = first_channel;
4463+
continue;
4464+
}
4465+
if (channel->ch_to_be_freed || channel->ch_killing)
4466+
{
4467+
channel_free_contents(channel);
4468+
if (channel->ch_job != NULL)
4469+
channel->ch_job->jv_channel = NULL;
44704470

4471-
// free the channel and then start over
4472-
channel_free_channel(channel);
4473-
channel = first_channel;
4474-
continue;
4475-
}
4476-
if (channel->ch_refcount == 0 && !channel_still_useful(channel))
4477-
{
4478-
// channel is no longer useful, free it
4479-
channel_free(channel);
4480-
channel = first_channel;
4481-
part = PART_SOCK;
4482-
continue;
4471+
// free the channel and then start over
4472+
channel_free_channel(channel);
4473+
channel = first_channel;
4474+
continue;
4475+
}
4476+
if (channel->ch_refcount == 0 && !channel_still_useful(channel))
4477+
{
4478+
// channel is no longer useful, free it
4479+
channel_free(channel);
4480+
channel = first_channel;
4481+
part = PART_SOCK;
4482+
continue;
4483+
}
44834484
}
4485+
44844486
if (channel->ch_part[part].ch_fd != INVALID_FD
44854487
|| channel_has_readahead(channel, part))
44864488
{
@@ -4521,7 +4523,7 @@ channel_parse_messages(void)
45214523
}
45224524

45234525
--safe_to_invoke_callback;
4524-
recursive = FALSE;
4526+
--recursive;
45254527

45264528
return ret;
45274529
}

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ static char *(features[]) =
738738

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
466,
741743
/**/
742744
465,
743745
/**/

0 commit comments

Comments
 (0)