[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-98]
don't unlink a Channel until the server closes it too when close()'ing a Channel, don't immediately unlink it from the Transport. instead, wait for the server to send a close message. this should fix a bug where doing close() on an EOF'd channel would cause the entire transport to be killed, because the server would send an 'exit-status' and 'close' message for a channel that we no longer had a record of.
This commit is contained in:
parent
d7caa20213
commit
6eb59a2b53
|
@ -359,9 +359,10 @@ class Channel (object):
|
|||
is flushed). Channels are automatically closed when they are garbage-
|
||||
collected, or when their L{Transport} is closed.
|
||||
"""
|
||||
try:
|
||||
self.lock.acquire()
|
||||
if self.active and not self.closed:
|
||||
try:
|
||||
if not self.active or self.closed:
|
||||
return
|
||||
try:
|
||||
self._send_eof()
|
||||
m = Message()
|
||||
|
@ -371,7 +372,8 @@ class Channel (object):
|
|||
except EOFError:
|
||||
pass
|
||||
self._set_closed()
|
||||
self.transport._unlink_channel(self.chanid)
|
||||
# can't unlink from the Transport yet -- the remote side may still
|
||||
# try to send meta-data (exit-status, etc)
|
||||
finally:
|
||||
self.lock.release()
|
||||
|
||||
|
@ -722,10 +724,9 @@ class Channel (object):
|
|||
|
||||
def _handle_close(self, m):
|
||||
self.close()
|
||||
try:
|
||||
self.lock.acquire()
|
||||
self.in_buffer_cv.notifyAll()
|
||||
self.out_buffer_cv.notifyAll()
|
||||
try:
|
||||
self.transport._unlink_channel(self.chanid)
|
||||
if self.pipe_wfd != None:
|
||||
os.close(self.pipe_wfd)
|
||||
self.pipe_wfd = None
|
||||
|
|
Loading…
Reference in New Issue