Mercurial > vim
comparison src/channel.c @ 19820:49e38e5472e6 v8.2.0466
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Commit: https://github.com/vim/vim/commit/09c569038c42dcbdaa5c9b35fc9d1afbe5072cb4
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 28 18:06:31 2020 +0100
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 28 Mar 2020 18:15:04 +0100 |
parents | d73d982499ae |
children | 435726a03481 |
comparison
equal
deleted
inserted
replaced
19819:b08a044fe7e7 | 19820:49e38e5472e6 |
---|---|
4426 { | 4426 { |
4427 channel_T *channel = first_channel; | 4427 channel_T *channel = first_channel; |
4428 int ret = FALSE; | 4428 int ret = FALSE; |
4429 int r; | 4429 int r; |
4430 ch_part_T part = PART_SOCK; | 4430 ch_part_T part = PART_SOCK; |
4431 static int recursive = FALSE; | 4431 static int recursive = 0; |
4432 #ifdef ELAPSED_FUNC | 4432 #ifdef ELAPSED_FUNC |
4433 elapsed_T start_tv; | 4433 elapsed_T start_tv; |
4434 #endif | 4434 #endif |
4435 | 4435 |
4436 // The code below may invoke callbacks, which might call us back. | 4436 // The code below may invoke callbacks, which might call us back. |
4437 // That doesn't work well, just return without doing anything. | 4437 // In a recursive call channels will not be closed. |
4438 if (recursive) | 4438 ++recursive; |
4439 return FALSE; | |
4440 recursive = TRUE; | |
4441 ++safe_to_invoke_callback; | 4439 ++safe_to_invoke_callback; |
4442 | 4440 |
4443 #ifdef ELAPSED_FUNC | 4441 #ifdef ELAPSED_FUNC |
4444 ELAPSED_INIT(start_tv); | 4442 ELAPSED_INIT(start_tv); |
4445 #endif | 4443 #endif |
4452 // now we should also give the message for SafeState | 4450 // now we should also give the message for SafeState |
4453 did_repeated_msg = REPEATED_MSG_LOOKING; | 4451 did_repeated_msg = REPEATED_MSG_LOOKING; |
4454 } | 4452 } |
4455 while (channel != NULL) | 4453 while (channel != NULL) |
4456 { | 4454 { |
4457 if (channel_can_close(channel)) | 4455 if (recursive == 1) |
4458 { | 4456 { |
4459 channel->ch_to_be_closed = (1U << PART_COUNT); | 4457 if (channel_can_close(channel)) |
4460 channel_close_now(channel); | 4458 { |
4461 // channel may have been freed, start over | 4459 channel->ch_to_be_closed = (1U << PART_COUNT); |
4462 channel = first_channel; | 4460 channel_close_now(channel); |
4463 continue; | 4461 // channel may have been freed, start over |
4464 } | 4462 channel = first_channel; |
4465 if (channel->ch_to_be_freed || channel->ch_killing) | 4463 continue; |
4466 { | 4464 } |
4467 channel_free_contents(channel); | 4465 if (channel->ch_to_be_freed || channel->ch_killing) |
4468 if (channel->ch_job != NULL) | 4466 { |
4469 channel->ch_job->jv_channel = NULL; | 4467 channel_free_contents(channel); |
4470 | 4468 if (channel->ch_job != NULL) |
4471 // free the channel and then start over | 4469 channel->ch_job->jv_channel = NULL; |
4472 channel_free_channel(channel); | 4470 |
4473 channel = first_channel; | 4471 // free the channel and then start over |
4474 continue; | 4472 channel_free_channel(channel); |
4475 } | 4473 channel = first_channel; |
4476 if (channel->ch_refcount == 0 && !channel_still_useful(channel)) | 4474 continue; |
4477 { | 4475 } |
4478 // channel is no longer useful, free it | 4476 if (channel->ch_refcount == 0 && !channel_still_useful(channel)) |
4479 channel_free(channel); | 4477 { |
4480 channel = first_channel; | 4478 // channel is no longer useful, free it |
4481 part = PART_SOCK; | 4479 channel_free(channel); |
4482 continue; | 4480 channel = first_channel; |
4483 } | 4481 part = PART_SOCK; |
4482 continue; | |
4483 } | |
4484 } | |
4485 | |
4484 if (channel->ch_part[part].ch_fd != INVALID_FD | 4486 if (channel->ch_part[part].ch_fd != INVALID_FD |
4485 || channel_has_readahead(channel, part)) | 4487 || channel_has_readahead(channel, part)) |
4486 { | 4488 { |
4487 // Increase the refcount, in case the handler causes the channel | 4489 // Increase the refcount, in case the handler causes the channel |
4488 // to be unreferenced or closed. | 4490 // to be unreferenced or closed. |
4519 channel_need_redraw = FALSE; | 4521 channel_need_redraw = FALSE; |
4520 redraw_after_callback(TRUE); | 4522 redraw_after_callback(TRUE); |
4521 } | 4523 } |
4522 | 4524 |
4523 --safe_to_invoke_callback; | 4525 --safe_to_invoke_callback; |
4524 recursive = FALSE; | 4526 --recursive; |
4525 | 4527 |
4526 return ret; | 4528 return ret; |
4527 } | 4529 } |
4528 | 4530 |
4529 /* | 4531 /* |