diff options
author | Erik Johnston <erik@matrix.org> | 2017-05-23 10:48:13 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2018-02-15 09:51:09 +0000 |
commit | 841bcbcafa6c5ba3663fd5ce3b3f83554d8c7f71 (patch) | |
tree | d78991103958303487ad355475af92141ff1ce85 /synapse/handlers/room_member.py | |
parent | Disable presence (diff) | |
download | synapse-841bcbcafa6c5ba3663fd5ce3b3f83554d8c7f71.tar.xz |
Limit concurrent AS joins
Diffstat (limited to 'synapse/handlers/room_member.py')
-rw-r--r-- | synapse/handlers/room_member.py | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/synapse/handlers/room_member.py b/synapse/handlers/room_member.py index 37dc5e99ab..703c9a3a97 100644 --- a/synapse/handlers/room_member.py +++ b/synapse/handlers/room_member.py @@ -28,7 +28,7 @@ from synapse.api.constants import ( ) from synapse.api.errors import AuthError, SynapseError, Codes from synapse.types import UserID, RoomID -from synapse.util.async import Linearizer +from synapse.util.async import Linearizer, Limiter from synapse.util.distributor import user_left_room, user_joined_room from ._base import BaseHandler @@ -50,6 +50,7 @@ class RoomMemberHandler(BaseHandler): self.event_creation_hander = hs.get_event_creation_handler() self.member_linearizer = Linearizer(name="member") + self.member_limiter = Limiter(3) self.clock = hs.get_clock() self.spam_checker = hs.get_spam_checker() @@ -161,18 +162,23 @@ class RoomMemberHandler(BaseHandler): ): key = (room_id,) - with (yield self.member_linearizer.queue(key)): - result = yield self._update_membership( - requester, - target, - room_id, - action, - txn_id=txn_id, - remote_room_hosts=remote_room_hosts, - third_party_signed=third_party_signed, - ratelimit=ratelimit, - content=content, - ) + as_id = object() + if requester.app_service: + as_id = requester.app_service.id + + with (yield self.member_limiter.queue(as_id)): + with (yield self.member_linearizer.queue(key)): + result = yield self._update_membership( + requester, + target, + room_id, + action, + txn_id=txn_id, + remote_room_hosts=remote_room_hosts, + third_party_signed=third_party_signed, + ratelimit=ratelimit, + content=content, + ) defer.returnValue(result) |