forked from aniani/vim
patch 7.4.1249
Problem: Crash when the process a channel is connected to exits. Solution: Use the file descriptor properly. Add a test. (Damien) Also add a test for eval().
This commit is contained in:
@@ -52,7 +52,6 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||
decoded = [-1, '']
|
||||
|
||||
# Send a response if the sequence number is positive.
|
||||
# Negative numbers are used for "eval" responses.
|
||||
if decoded[0] >= 0:
|
||||
if decoded[1] == 'hello!':
|
||||
# simply send back a string
|
||||
@@ -65,9 +64,27 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||
print("sending: {}".format(cmd))
|
||||
thesocket.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'eval-works':
|
||||
# Send an eval request. We ignore the response.
|
||||
cmd = '["eval","\\"foo\\" . 123", -1]'
|
||||
print("sending: {}".format(cmd))
|
||||
thesocket.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'eval-fails':
|
||||
# Send an eval request that will fail.
|
||||
cmd = '["eval","xxx", -2]'
|
||||
print("sending: {}".format(cmd))
|
||||
thesocket.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'eval-result':
|
||||
# Send back the last received eval result.
|
||||
response = last_eval
|
||||
elif decoded[1] == '!quit!':
|
||||
# we're done
|
||||
sys.exit(0)
|
||||
elif decoded[1] == '!crash!':
|
||||
# Crash!
|
||||
42 / 0
|
||||
else:
|
||||
response = "what?"
|
||||
|
||||
@@ -75,6 +92,10 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||
print("sending: {}".format(encoded))
|
||||
thesocket.sendall(encoded.encode('utf-8'))
|
||||
|
||||
# Negative numbers are used for "eval" responses.
|
||||
elif decoded[0] < 0:
|
||||
last_eval = decoded
|
||||
|
||||
thesocket = None
|
||||
|
||||
class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
|
||||
|
Reference in New Issue
Block a user