1
0
forked from aniani/vim

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)
This commit is contained in:
Bram Moolenaar
2018-09-06 16:27:24 +02:00
parent ed5a9d6612
commit 0b1468884a
5 changed files with 62 additions and 2 deletions

View File

@@ -1180,6 +1180,7 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
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_any_keep_open()
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 @@ channel_send(
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 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
== 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)