webssh

Web based ssh client https://github.com/huashengdun/webssh webssh.huashengdun.org/
git clone http://git.hanabi.in/repos/webssh.git
Log | Files | Refs | README | LICENSE

commit 86abf6912d459d27fab0fac018f65a54308cb0de
parent ec545ec463636457a22c1d6e54e896dc9afe83c6
Author: Sheng <webmaster0115@gmail.com>
Date:   Wed,  3 Jul 2019 19:50:35 +0800

Check worker status before closing worker

Diffstat:
Mwebssh/handler.py | 10++--------
Mwebssh/worker.py | 5+++++
2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/webssh/handler.py b/webssh/handler.py @@ -462,15 +462,9 @@ class WsockHandler(MixinHandler, tornado.websocket.WebSocketHandler): worker.on_write() def on_close(self): - if self.close_reason: - logging.info( - 'Disconnecting to {}:{} with reason: {reason}'.format( - *self.src_addr, reason=self.close_reason - ) - ) - else: + logging.info('Disconnected from {}:{}'.format(*self.src_addr)) + if not self.close_reason: self.close_reason = 'client disconnected' - logging.info('Disconnected from {}:{}'.format(*self.src_addr)) worker = self.worker_ref() if self.worker_ref else None if worker: diff --git a/webssh/worker.py b/webssh/worker.py @@ -29,6 +29,7 @@ class Worker(object): self.data_to_dst = [] self.handler = None self.mode = IOLoop.READ + self.closed = False def __call__(self, fd, events): if events & IOLoop.READ: @@ -95,6 +96,10 @@ class Worker(object): self.update_handler(IOLoop.READ) def close(self, reason=None): + if self.closed: + return + self.closed = True + logging.info( 'Closing worker {} with reason: {}'.format(self.id, reason) )