summaryrefslogtreecommitdiffstats
path: root/src/channel.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-02-10 22:23:26 +0100
committerBram Moolenaar <Bram@vim.org>2019-02-10 22:23:26 +0100
commit6524068ff3252f1373807f1ebfde21408cef624e (patch)
tree016c761632389af45db753da47049f2d0ce0a688 /src/channel.c
parent31b816042fca879b11965ddd75287732563ba698 (diff)
patch 8.1.0889: MS-Windows: a channel write may hangv8.1.0889
Problem: MS-Windows: a channel write may hang. Solution: Check for WriteFile() not writing anything. (Yasuhiro Matsumoto, closes #3920)
Diffstat (limited to 'src/channel.c')
-rw-r--r--src/channel.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/channel.c b/src/channel.c
index 34a1fc3e03..d728c77d9f 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -91,9 +91,10 @@ fd_write(sock_T fd, char *buf, size_t len)
size = MAX_NAMED_PIPE_SIZE;
else
size = (DWORD)todo;
- // If the pipe overflows while the job does not read the data, WriteFile
- // will block forever. This abandons the write.
+ // If the pipe overflows while the job does not read the data,
+ // WriteFile() will block forever. This abandons the write.
memset(&ov, 0, sizeof(ov));
+ nwrite = 0;
if (!WriteFile(h, buf + done, size, &nwrite, &ov))
{
DWORD err = GetLastError();
@@ -104,6 +105,10 @@ fd_write(sock_T fd, char *buf, size_t len)
return -1;
FlushFileBuffers(h);
}
+ else if (nwrite == 0)
+ // WriteFile() returns TRUE but did not write anything. This causes
+ // a hang, so bail out.
+ break;
todo -= nwrite;
done += nwrite;
}