From bd9b8d87ae08e3601631e86c54e95c7f53dd3b17 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 2 Sep 2016 13:40:07 +0100 Subject: [PATCH 1/3] Only check if host is in room if we have state and auth_chain --- synapse/handlers/federation.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 8e61d74b1..ca51044ae 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -118,12 +118,18 @@ class FederationHandler(BaseHandler): # FIXME (erikj): Awful hack to make the case where we are not currently # in the room work - is_in_room = yield self.auth.check_host_in_room( - event.room_id, - self.server_name - ) - if not is_in_room and not event.internal_metadata.is_outlier(): - logger.debug("Got event for room we're not in.") + if state and auth_chain and not event.internal_metadata.is_outlier(): + is_in_room = yield self.auth.check_host_in_room( + event.room_id, + self.server_name + ) + else: + is_in_room = True + if not is_in_room: + logger.info( + "Got event for room we're not in: %r %r", + event.room_id, event.event_id + ) try: event_stream_id, max_stream_id = yield self._persist_auth_tree( From 34e5e17f916d50027939582f1fd9d399592ba63f Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 2 Sep 2016 14:26:07 +0100 Subject: [PATCH 2/3] Comment --- synapse/handlers/federation.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index ca51044ae..2338c3a72 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -118,6 +118,9 @@ class FederationHandler(BaseHandler): # FIXME (erikj): Awful hack to make the case where we are not currently # in the room work + # If state and auth_chain are None, then we don't need to do this check + # as we already know we have enough state in the DB to handle this + # event. if state and auth_chain and not event.internal_metadata.is_outlier(): is_in_room = yield self.auth.check_host_in_room( event.room_id, From f7f1027d3d5d2c8a92fbe36eccf2008d823fc2b1 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 2 Sep 2016 14:42:38 +0100 Subject: [PATCH 3/3] Comment on when auth chain and state are None --- synapse/handlers/federation.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 2338c3a72..fa7ea6385 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -101,6 +101,9 @@ class FederationHandler(BaseHandler): def on_receive_pdu(self, origin, pdu, state=None, auth_chain=None): """ Called by the ReplicationLayer when we have a new pdu. We need to do auth checks and put it through the StateHandler. + + auth_chain and state are None if we already have the necessary state + and prev_events in the db """ event = pdu