mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
tornado: Fix race condition on handler._request.
Commit6fd1a558b7(#21469) introduced an await point where get_events_backend calls fetch_events in order to switch threads. This opened the possibility that, in the window between the connect_handler call in fetch_events and the old location of this assignment in get_events_backend, an event could arrive, causing ClientDescriptor.add_event to crash on missing handler._request. Fix this by assigning handler._request earlier. Signed-off-by: Anders Kaseorg <anders@zulip.com> (cherry picked from commite112b619cc)
This commit is contained in:
committed by
Tim Abbott
parent
c9e00e6391
commit
82155e15a5
@@ -125,6 +125,7 @@ def get_events_backend(
|
||||
assert tornado_handler is not None
|
||||
handler = tornado_handler()
|
||||
assert handler is not None
|
||||
handler._request = request
|
||||
|
||||
if user_client is None:
|
||||
valid_user_client = RequestNotes.get_notes(request).client
|
||||
@@ -173,7 +174,6 @@ def get_events_backend(
|
||||
# Mark this response with .asynchronous; this will result in
|
||||
# Tornado discarding the response and instead long-polling the
|
||||
# request. See zulip_finish for more design details.
|
||||
handler._request = request
|
||||
response = json_success(request)
|
||||
response.asynchronous = True
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user