[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-13]
fix a deadlock/race in handle_eof & close (patch from fred gansevles) add locking around the eof handler and the close() call, so we can't be in both simultaneously.
This commit is contained in:
parent
02319afd5a
commit
f6e1e84d60
10
channel.py
10
channel.py
|
@ -158,9 +158,10 @@ class Channel(object):
|
|||
self.transport.send_message(m)
|
||||
|
||||
def handle_eof(self, m):
|
||||
self.eof_received = 1
|
||||
try:
|
||||
self.lock.acquire()
|
||||
if not self.eof_received:
|
||||
self.eof_received = 1
|
||||
self.in_buffer_cv.notifyAll()
|
||||
if self.pipe_wfd != None:
|
||||
os.close(self.pipe_wfd)
|
||||
|
@ -282,8 +283,9 @@ class Channel(object):
|
|||
self.settimeout(0.0)
|
||||
|
||||
def close(self):
|
||||
if self.closed or not self.active:
|
||||
return
|
||||
try:
|
||||
self.lock.acquire()
|
||||
if self.active and not self.closed:
|
||||
self.send_eof()
|
||||
m = Message()
|
||||
m.add_byte(chr(MSG_CHANNEL_CLOSE))
|
||||
|
@ -291,6 +293,8 @@ class Channel(object):
|
|||
self.transport.send_message(m)
|
||||
self.closed = 1
|
||||
self.transport.unlink_channel(self.chanid)
|
||||
finally:
|
||||
self.lock.release()
|
||||
|
||||
def recv_ready(self):
|
||||
"doesn't work if you've called fileno()"
|
||||
|
|
Loading…
Reference in New Issue