Skip to content

Commit d75263c

Browse files
committed
patch 7.4.1807
Problem: Test_out_close_cb sometimes fails. Solution: Always write DETACH to out, not err.
1 parent 8e3d1b6 commit d75263c

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/channel.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2478,6 +2478,7 @@ channel_close(channel_T *channel, int invoke_close_cb)
24782478
* first invoke the close callback. Increment the refcount to avoid
24792479
* the channel being freed halfway. */
24802480
++channel->ch_refcount;
2481+
ch_log(channel, "Invoking callbacks before closing");
24812482
for (part = PART_SOCK; part <= PART_ERR; ++part)
24822483
while (may_invoke_callback(channel, part))
24832484
;
@@ -2783,7 +2784,7 @@ channel_close_on_error(channel_T *channel, int part, char *func)
27832784
*/
27842785
if (channel->ch_part[part].ch_mode == MODE_RAW
27852786
|| channel->ch_part[part].ch_mode == MODE_NL)
2786-
channel_save(channel, part, (char_u *)DETACH_MSG_RAW,
2787+
channel_save(channel, PART_OUT, (char_u *)DETACH_MSG_RAW,
27872788
(int)STRLEN(DETACH_MSG_RAW), FALSE, "PUT ");
27882789

27892790
/* When reading from stdout is not possible, assume the other side has

src/testdir/test_channel.vim

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,10 +1055,15 @@ func Test_out_close_cb()
10551055
call ch_log('Test_out_close_cb()')
10561056

10571057
let s:counter = 1
1058-
let s:outmsg = 0
1058+
let s:msg1 = ''
1059+
let s:msg2 = ''
10591060
let s:closemsg = 0
10601061
func! OutHandler(chan, msg)
1061-
let s:outmsg = s:counter
1062+
if s:counter == 1
1063+
let s:msg1 = a:msg
1064+
else
1065+
let s:msg2 = a:msg
1066+
endif
10621067
let s:counter += 1
10631068
endfunc
10641069
func! CloseHandler(chan)
@@ -1070,9 +1075,10 @@ func Test_out_close_cb()
10701075
\ 'close_cb': 'CloseHandler'})
10711076
call assert_equal("run", job_status(job))
10721077
try
1073-
call s:waitFor('s:closemsg != 0 && s:outmsg != 0')
1074-
call assert_equal(1, s:outmsg)
1075-
call assert_equal(2, s:closemsg)
1078+
call s:waitFor('s:closemsg != 0 && s:msg2 != ""')
1079+
call assert_equal('quit', s:msg1)
1080+
call assert_equal('DETACH', s:msg2)
1081+
call assert_equal(3, s:closemsg)
10761082
finally
10771083
call job_stop(job)
10781084
delfunc OutHandler

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,8 @@ static char *(features[]) =
753753

754754
static int included_patches[] =
755755
{ /* Add new patch number below this line */
756+
/**/
757+
1807,
756758
/**/
757759
1806,
758760
/**/

0 commit comments

Comments
 (0)