summaryrefslogtreecommitdiff
path: root/src/channel.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-11-24 17:22:50 +0100
committerBram Moolenaar <Bram@vim.org>2016-11-24 17:22:50 +0100
commit833eb1d752426689051bf2001083359899536939 (patch)
treef91eeead037b689d8d02bd1e47704332a63d7de0 /src/channel.c
parent2cab0e191055a8145ccd46cd52869fbb9798b971 (diff)
downloadvim-833eb1d752426689051bf2001083359899536939.zip
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.
Diffstat (limited to 'src/channel.c')
-rw-r--r--src/channel.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/channel.c b/src/channel.c
index 778a30e17..19520e200 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -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;