diff src/testdir/test_channel.vim @ 8074:dc32c8026899 v7.4.1331

commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Feb 16 13:33:52 2016 +0100 patch 7.4.1331 Problem: Crash when closing the channel in a callback. (Christian J. Robinson) Solution: Take the callback out of the list before invoking it.
author Christian Brabandt <cb@256bit.org>
date Tue, 16 Feb 2016 13:45:04 +0100
parents e4c3f6720b03
children 7676818d486b
line wrap: on
line diff
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -301,6 +301,8 @@ func Test_pipe()
   endtry
 endfunc
 
+""""""""""
+
 let s:unletResponse = ''
 func s:UnletHandler(handle, msg)
   let s:unletResponse = a:msg
@@ -319,6 +321,28 @@ func Test_unlet_handle()
   call s:run_server('s:unlet_handle')
 endfunc
 
+""""""""""
+
+let s:unletResponse = ''
+func s:CloseHandler(handle, msg)
+  let s:unletResponse = a:msg
+  call ch_close(s:channelfd)
+endfunc
+
+" Test that "unlet handle" in a handler doesn't crash Vim.
+func s:close_handle(port)
+  let s:channelfd = ch_open('localhost:' . a:port, s:chopt)
+  call ch_sendexpr(s:channelfd, "test", function('s:CloseHandler'))
+  sleep 10m
+  call assert_equal('what?', s:unletResponse)
+endfunc
+
+func Test_close_handle()
+  call s:run_server('s:close_handle')
+endfunc
+
+""""""""""
+
 func Test_open_fail()
   silent! let ch = ch_open("noserver")
   echo ch