0
0
mirror of https://github.com/vim/vim.git synced 2025-11-15 23:14:06 -05:00

patch 8.0.0097

Problem:    When a channel callback consumes a lot of time Vim becomes
            unresponsive. (skywind)
Solution:   Bail out of checking channel readahead after 100 msec.
This commit is contained in:
Bram Moolenaar
2016-11-24 17:22:50 +01:00
parent 2cab0e1910
commit 833eb1d752
6 changed files with 88 additions and 48 deletions

View File

@@ -3815,6 +3815,11 @@ channel_parse_messages(void)
int ret = FALSE;
int r;
ch_part_T part = PART_SOCK;
#ifdef ELAPSED_FUNC
ELAPSED_TYPE start_tv;
ELAPSED_INIT(start_tv);
#endif
++safe_to_invoke_callback;
@@ -3859,7 +3864,14 @@ channel_parse_messages(void)
r = may_invoke_callback(channel, part);
if (r == OK)
ret = TRUE;
if (channel_unref(channel) || r == OK)
if (channel_unref(channel) || (r == OK
#ifdef ELAPSED_FUNC
/* Limit the time we loop here to 100 msec, otherwise
* Vim becomes unresponsive when the callback takes
* more than a bit of time. */
&& ELAPSED_FUNC(start_tv) < 100L
#endif
))
{
/* channel was freed or something was done, start over */
channel = first_channel;