mirror of
https://github.com/huashengdun/webssh.git
synced 2026-05-01 23:17:05 +00:00
Check worker status before closing worker
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user