From 19d816f9914f765e5cc8f1e48386e5d8e5eac4cc Mon Sep 17 00:00:00 2001 From: Sheng Date: Wed, 16 Sep 2020 21:01:53 +0800 Subject: [PATCH] Check if channel is closed first when error occurs on reading or writing --- webssh/worker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webssh/worker.py b/webssh/worker.py index 0f47d57..098538e 100644 --- a/webssh/worker.py +++ b/webssh/worker.py @@ -67,7 +67,7 @@ class Worker(object): data = self.chan.recv(BUF_SIZE) except (OSError, IOError) as e: logging.error(e) - if errno_from_exception(e) in _ERRNO_CONNRESET: + if self.chan.closed or errno_from_exception(e) in _ERRNO_CONNRESET: self.close(reason='chan error on reading') else: logging.debug('{!r} from {}:{}'.format(data, *self.dst_addr)) @@ -93,7 +93,7 @@ class Worker(object): sent = self.chan.send(data) except (OSError, IOError) as e: logging.error(e) - if errno_from_exception(e) in _ERRNO_CONNRESET: + if self.chan.closed or errno_from_exception(e) in _ERRNO_CONNRESET: self.close(reason='chan error on writing') else: self.update_handler(IOLoop.WRITE)