Skip to content

Instantly share code, notes, and snippets.

@l04m33
Created February 6, 2017 10:39
Show Gist options
  • Save l04m33/d1c910f854d19520101dc1bc332277eb to your computer and use it in GitHub Desktop.
Save l04m33/d1c910f854d19520101dc1bc332277eb to your computer and use it in GitHub Desktop.
Reproducing Vim channel_fill(...) issue
if exists('g:dummy_chan')
silent! call ch_close(g:dummy_chan)
endif
function! DummyCB(chan, msg)
echom '>>>> msg: ' . string(a:msg)
endfunction
let g:dummy_chan = ch_open('127.0.0.1:9999',
\ {'mode': 'json',
\ 'callback': function('DummyCB')})
import socket
import time
s = socket.socket()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
s.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, True)
s.bind(('127.0.0.1', 9999))
s.listen(1)
ss, _ = s.accept()
s.close()
ss.send(b'[0,{"a":1,"b":2}]\r\n')
print('ref msg sent, sleeping')
time.sleep(1)
fragments = [(b'[0,["' + b'x' * 4096 + b'",', 0), (b'"' + b'y' * 1024 + b'"]]\r\n', 0)]
for f, timeout in fragments:
ss.send(f)
print('fragment sent, sleeping')
time.sleep(timeout)
ss.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment