Mercurial > vim
comparison src/channel.c @ 14675:71c17b688bc6 v8.1.0350
patch 8.1.0350: Vim may block on ch_sendraw()
commit https://github.com/vim/vim/commit/0b1468884a2a1c5d3442cbb7119330e307f0aa3d
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Sep 6 16:27:24 2018 +0200
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 06 Sep 2018 16:30:06 +0200 |
parents | 2661d77e440e |
children | 193471015e1a |
comparison
equal
deleted
inserted
replaced
14674:ab03bc29a3d3 | 14675:71c17b688bc6 |
---|---|
1178 channel->ch_part[PART_IN].ch_mode = opt->jo_in_mode; | 1178 channel->ch_part[PART_IN].ch_mode = opt->jo_in_mode; |
1179 if (opt->jo_set & JO_OUT_MODE) | 1179 if (opt->jo_set & JO_OUT_MODE) |
1180 channel->ch_part[PART_OUT].ch_mode = opt->jo_out_mode; | 1180 channel->ch_part[PART_OUT].ch_mode = opt->jo_out_mode; |
1181 if (opt->jo_set & JO_ERR_MODE) | 1181 if (opt->jo_set & JO_ERR_MODE) |
1182 channel->ch_part[PART_ERR].ch_mode = opt->jo_err_mode; | 1182 channel->ch_part[PART_ERR].ch_mode = opt->jo_err_mode; |
1183 channel->ch_nonblock = opt->jo_noblock; | |
1183 | 1184 |
1184 if (opt->jo_set & JO_TIMEOUT) | 1185 if (opt->jo_set & JO_TIMEOUT) |
1185 for (part = PART_SOCK; part < PART_COUNT; ++part) | 1186 for (part = PART_SOCK; part < PART_COUNT; ++part) |
1186 channel->ch_part[part].ch_timeout = opt->jo_timeout; | 1187 channel->ch_part[part].ch_timeout = opt->jo_timeout; |
1187 if (opt->jo_set & JO_OUT_TIMEOUT) | 1188 if (opt->jo_set & JO_OUT_TIMEOUT) |
3675 */ | 3676 */ |
3676 void | 3677 void |
3677 channel_set_nonblock(channel_T *channel, ch_part_T part) | 3678 channel_set_nonblock(channel_T *channel, ch_part_T part) |
3678 { | 3679 { |
3679 chanpart_T *ch_part = &channel->ch_part[part]; | 3680 chanpart_T *ch_part = &channel->ch_part[part]; |
3680 int fd = ch_part->ch_fd; | 3681 int fd = ch_part->ch_fd; |
3681 | 3682 |
3682 if (fd != INVALID_FD) | 3683 if (fd != INVALID_FD) |
3683 { | 3684 { |
3684 #ifdef _WIN32 | 3685 #ifdef _WIN32 |
3685 u_long val = 1; | 3686 u_long val = 1; |
3719 EMSG2(_("E630: %s(): write while not connected"), fun); | 3720 EMSG2(_("E630: %s(): write while not connected"), fun); |
3720 } | 3721 } |
3721 channel->ch_error = TRUE; | 3722 channel->ch_error = TRUE; |
3722 return FAIL; | 3723 return FAIL; |
3723 } | 3724 } |
3725 | |
3726 if (channel->ch_nonblock && !ch_part->ch_nonblocking) | |
3727 channel_set_nonblock(channel, part); | |
3724 | 3728 |
3725 if (ch_log_active()) | 3729 if (ch_log_active()) |
3726 { | 3730 { |
3727 ch_log_lead("SEND ", channel, part); | 3731 ch_log_lead("SEND ", channel, part); |
3728 fprintf(log_fd, "'"); | 3732 fprintf(log_fd, "'"); |
4551 break; | 4555 break; |
4552 if (handle_mode(item, opt, &opt->jo_err_mode, JO_ERR_MODE) | 4556 if (handle_mode(item, opt, &opt->jo_err_mode, JO_ERR_MODE) |
4553 == FAIL) | 4557 == FAIL) |
4554 return FAIL; | 4558 return FAIL; |
4555 } | 4559 } |
4560 else if (STRCMP(hi->hi_key, "noblock") == 0) | |
4561 { | |
4562 if (!(supported & JO_MODE)) | |
4563 break; | |
4564 opt->jo_noblock = get_tv_number(item); | |
4565 } | |
4556 else if (STRCMP(hi->hi_key, "in_io") == 0 | 4566 else if (STRCMP(hi->hi_key, "in_io") == 0 |
4557 || STRCMP(hi->hi_key, "out_io") == 0 | 4567 || STRCMP(hi->hi_key, "out_io") == 0 |
4558 || STRCMP(hi->hi_key, "err_io") == 0) | 4568 || STRCMP(hi->hi_key, "err_io") == 0) |
4559 { | 4569 { |
4560 if (!(supported & JO_OUT_IO)) | 4570 if (!(supported & JO_OUT_IO)) |