summaryrefslogtreecommitdiffstats
path: root/src/if_xcmdsrv.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-03-19 21:20:53 +0100
committerBram Moolenaar <Bram@vim.org>2017-03-19 21:20:53 +0100
commit81b9d0bd5c705815e903e671e81b0b05828efd9c (patch)
tree3e832c3269ad004ee414c81b5ddbd65ae93ad9d5 /src/if_xcmdsrv.c
parentbfd830d3e2dbd1e9b14c65625f18773074e6ac67 (diff)
patch 8.0.0492: a failing client-server request can make Vim hangv8.0.0492
Problem: A failing client-server request can make Vim hang. Solution: Add a timeout argument to functions that wait.
Diffstat (limited to 'src/if_xcmdsrv.c')
-rw-r--r--src/if_xcmdsrv.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/if_xcmdsrv.c b/src/if_xcmdsrv.c
index 9ff6d76056..4c3c012202 100644
--- a/src/if_xcmdsrv.c
+++ b/src/if_xcmdsrv.c
@@ -373,6 +373,7 @@ serverSendToVim(
char_u **result, /* Result of eval'ed expression */
Window *server, /* Actual ID of receiving app */
Bool asExpr, /* Interpret as keystrokes or expr ? */
+ int timeout, /* seconds to wait or zero */
Bool localLoop, /* Throw away everything but result */
int silent) /* don't complain about no server */
{
@@ -485,7 +486,8 @@ serverSendToVim(
pending.nextPtr = pendingCommands;
pendingCommands = &pending;
- ServerWait(dpy, w, WaitForPend, &pending, localLoop, 600);
+ ServerWait(dpy, w, WaitForPend, &pending, localLoop,
+ timeout > 0 ? timeout : 600);
/*
* Unregister the information about the pending command
@@ -790,6 +792,7 @@ WaitForReply(void *p)
/*
* Wait for replies from id (win)
+ * When "timeout" is non-zero wait up to this many seconds.
* Return 0 and the malloc'ed string when a reply is available.
* Return -1 if the window becomes invalid while waiting.
*/
@@ -798,13 +801,15 @@ serverReadReply(
Display *dpy,
Window win,
char_u **str,
- int localLoop)
+ int localLoop,
+ int timeout)
{
int len;
char_u *s;
struct ServerReply *p;
- ServerWait(dpy, win, WaitForReply, &win, localLoop, -1);
+ ServerWait(dpy, win, WaitForReply, &win, localLoop,
+ timeout > 0 ? timeout : -1);
if ((p = ServerReplyFind(win, SROP_Find)) != NULL && p->strings.ga_len > 0)
{