summary refs log tree commit diff
path: root/synapse/federation
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-02-12 18:17:11 +0000
committerErik Johnston <erik@matrix.org>2015-02-12 18:17:11 +0000
commit963256638d5b3c3edee14bfbd7c00944b45d04c0 (patch)
tree1dea83e095f847f538dc0aa3b1aad47e55b60788 /synapse/federation
parentMerge branch 'master' of github.com:matrix-org/synapse into develop (diff)
downloadsynapse-963256638d5b3c3edee14bfbd7c00944b45d04c0.tar.xz
Correctly handle all the places that can throw exceptions
Diffstat (limited to 'synapse/federation')
-rw-r--r--synapse/federation/federation_base.py24
-rw-r--r--synapse/federation/federation_server.py9
2 files changed, 20 insertions, 13 deletions
diff --git a/synapse/federation/federation_base.py b/synapse/federation/federation_base.py
index a990aec4fd..30f3f5c8a4 100644
--- a/synapse/federation/federation_base.py
+++ b/synapse/federation/federation_base.py
@@ -61,7 +61,8 @@ class FederationBase(object):
                 # Check local db.
                 new_pdu = yield self.store.get_event(
                     pdu.event_id,
-                    allow_rejected=True
+                    allow_rejected=True,
+                    allow_none=True,
                 )
                 if new_pdu:
                     signed_pdus.append(new_pdu)
@@ -69,15 +70,18 @@ class FederationBase(object):
 
                 # Check pdu.origin
                 if pdu.origin != origin:
-                    new_pdu = yield self.get_pdu(
-                        destinations=[pdu.origin],
-                        event_id=pdu.event_id,
-                        outlier=outlier,
-                    )
-
-                    if new_pdu:
-                        signed_pdus.append(new_pdu)
-                        continue
+                    try:
+                        new_pdu = yield self.get_pdu(
+                            destinations=[pdu.origin],
+                            event_id=pdu.event_id,
+                            outlier=outlier,
+                        )
+
+                        if new_pdu:
+                            signed_pdus.append(new_pdu)
+                            continue
+                    except:
+                        pass
 
                 logger.warn("Failed to find copy of %s with valid signature")
 
diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py
index b23f72c7fa..9f5c98694c 100644
--- a/synapse/federation/federation_server.py
+++ b/synapse/federation/federation_server.py
@@ -411,9 +411,12 @@ class FederationServer(FederationBase):
                 "_handle_new_pdu getting state for %s",
                 pdu.room_id
             )
-            state, auth_chain = yield self.get_state_for_room(
-                origin, pdu.room_id, pdu.event_id,
-            )
+            try:
+                state, auth_chain = yield self.get_state_for_room(
+                    origin, pdu.room_id, pdu.event_id,
+                )
+            except:
+                logger.warn("Failed to get state for event: %s", pdu.event_id)
 
         ret = yield self.handler.on_receive_pdu(
             origin,