patch 8.1.0350: Vim may block on ch_sendraw()
Problem: Vim may block on ch_sendraw() when the job is sending data back to
Vim, which isn't read yet. (Nate Bosch)
Solution: Add the "noblock" option to job_start(). (closes #2548)
diff --git a/src/channel.c b/src/channel.c
index 282340e..793dbaa 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -1180,6 +1180,7 @@
channel->ch_part[PART_OUT].ch_mode = opt->jo_out_mode;
if (opt->jo_set & JO_ERR_MODE)
channel->ch_part[PART_ERR].ch_mode = opt->jo_err_mode;
+ channel->ch_nonblock = opt->jo_noblock;
if (opt->jo_set & JO_TIMEOUT)
for (part = PART_SOCK; part < PART_COUNT; ++part)
@@ -3677,7 +3678,7 @@
channel_set_nonblock(channel_T *channel, ch_part_T part)
{
chanpart_T *ch_part = &channel->ch_part[part];
- int fd = ch_part->ch_fd;
+ int fd = ch_part->ch_fd;
if (fd != INVALID_FD)
{
@@ -3722,6 +3723,9 @@
return FAIL;
}
+ if (channel->ch_nonblock && !ch_part->ch_nonblocking)
+ channel_set_nonblock(channel, part);
+
if (ch_log_active())
{
ch_log_lead("SEND ", channel, part);
@@ -4553,6 +4557,12 @@
== FAIL)
return FAIL;
}
+ else if (STRCMP(hi->hi_key, "noblock") == 0)
+ {
+ if (!(supported & JO_MODE))
+ break;
+ opt->jo_noblock = get_tv_number(item);
+ }
else if (STRCMP(hi->hi_key, "in_io") == 0
|| STRCMP(hi->hi_key, "out_io") == 0
|| STRCMP(hi->hi_key, "err_io") == 0)