Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
tornado: Explicitly remove handler when clients disconnect.
Alex Vandiver4af00f61a8c4
diff --git a/zerver/tornado/handlers.py b/zerver/tornado/handlers.pyindex 51a1229ecda..1f1fc13d367 100644--- a/zerver/tornado/handlers.py+++ b/zerver/tornado/handlers.py@@ -93,13 +93,17 @@ class AsyncDjangoHandler(tornado.web.RequestHandler):self._auto_finish = False# Handler IDs are allocated here, and the handler ID map must- # be cleared when the handler finishes its response+ # be cleared when the handler finishes its response. See+ # on_finish and on_connection_close.self.handler_id = allocate_handler_id(self)self._request: Optional[HttpRequest] = None@overridedef on_finish(self) -> None:+ # Note that this only runs on _successful_ requests. If the+ # client closes the connection, see on_connection_close,+ # below.clear_handler_by_id(self.handler_id)@override@@ -214,6 +218,10 @@ class AsyncDjangoHandler(tornado.web.RequestHandler):# proxy does not correctly close connections to Tornado when# its clients (e.g. `curl`) close their connections. This# code path is thus _unreachable except in production_.++ # If the client goes away, garbage collect the handler (with+ # attached request information).+ clear_handler_by_id(self.handler_id)client_descriptor = get_descriptor_by_handler_id(self.handler_id)if client_descriptor is not None:client_descriptor.disconnect_handler(client_closed=True)