* first invoke the close callback. Increment the refcount to avoid
* the channel being freed halfway. */
++channel->ch_refcount;
+ ch_log(channel, "Invoking callbacks before closing");
for (part = PART_SOCK; part <= PART_ERR; ++part)
while (may_invoke_callback(channel, part))
;
*/
if (channel->ch_part[part].ch_mode == MODE_RAW
|| channel->ch_part[part].ch_mode == MODE_NL)
- channel_save(channel, part, (char_u *)DETACH_MSG_RAW,
+ channel_save(channel, PART_OUT, (char_u *)DETACH_MSG_RAW,
(int)STRLEN(DETACH_MSG_RAW), FALSE, "PUT ");
/* When reading from stdout is not possible, assume the other side has
call ch_log('Test_out_close_cb()')
let s:counter = 1
- let s:outmsg = 0
+ let s:msg1 = ''
+ let s:msg2 = ''
let s:closemsg = 0
func! OutHandler(chan, msg)
- let s:outmsg = s:counter
+ if s:counter == 1
+ let s:msg1 = a:msg
+ else
+ let s:msg2 = a:msg
+ endif
let s:counter += 1
endfunc
func! CloseHandler(chan)
\ 'close_cb': 'CloseHandler'})
call assert_equal("run", job_status(job))
try
- call s:waitFor('s:closemsg != 0 && s:outmsg != 0')
- call assert_equal(1, s:outmsg)
- call assert_equal(2, s:closemsg)
+ call s:waitFor('s:closemsg != 0 && s:msg2 != ""')
+ call assert_equal('quit', s:msg1)
+ call assert_equal('DETACH', s:msg2)
+ call assert_equal(3, s:closemsg)
finally
call job_stop(job)
delfunc OutHandler