diff options
author | Richard van der Hoff <richard@matrix.org> | 2018-04-20 11:10:04 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2018-04-20 11:10:04 +0100 |
commit | 0c280d4d99e93d2fd9120a7ec93c0997d372adb4 (patch) | |
tree | b359b49f69f47dc523b2e176e55fff61779587e8 | |
parent | ResponseCache: fix handling of completed results (diff) | |
download | synapse-0c280d4d99e93d2fd9120a7ec93c0997d372adb4.tar.xz |
Reinstate linearizer for federation_server.on_context_state_request
-rw-r--r-- | synapse/federation/federation_server.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py index d1611f39a9..12843fe179 100644 --- a/synapse/federation/federation_server.py +++ b/synapse/federation/federation_server.py @@ -211,11 +211,17 @@ class FederationServer(FederationBase): if not in_room: raise AuthError(403, "Host not in room.") - resp = yield self._state_resp_cache.wrap( - (room_id, event_id), - self._on_context_state_request_compute, - room_id, event_id, - ) + # we grab the linearizer to protect ourselves from servers which hammer + # us. In theory we might already have the response to this query + # in the cache so we could return it without waiting for the linearizer + # - but that's non-trivial to get right, and anyway somewhat defeats + # the point of the linearizer. + with (yield self._server_linearizer.queue((origin, room_id))): + resp = yield self._state_resp_cache.wrap( + (room_id, event_id), + self._on_context_state_request_compute, + room_id, event_id, + ) defer.returnValue((200, resp)) |