summary refs log tree commit diff
path: root/synapse/federation/federation_server.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-03-02 13:53:30 +0000
committerErik Johnston <erik@matrix.org>2015-03-02 13:53:30 +0000
commit0a036944bd2f0b42195b1984ff0ad2b6ff3d50f3 (patch)
tree25ca81b14a72192a89c9399b3d80180ac124ca14 /synapse/federation/federation_server.py
parentMust update pending_transactions map before yield'ing (diff)
parentMerge pull request #83 from matrix-org/nofile_limit_config (diff)
downloadsynapse-0a036944bd2f0b42195b1984ff0ad2b6ff3d50f3.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into batched_get_pdu
Diffstat (limited to 'synapse/federation/federation_server.py')
-rw-r--r--synapse/federation/federation_server.py41
1 files changed, 13 insertions, 28 deletions
diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py
index f74e16abd5..4264d857be 100644
--- a/synapse/federation/federation_server.py
+++ b/synapse/federation/federation_server.py
@@ -112,17 +112,20 @@ class FederationServer(FederationBase):
         logger.debug("[%s] Transaction is new", transaction.transaction_id)
 
         with PreserveLoggingContext():
-            dl = []
+            results = []
+
             for pdu in pdu_list:
                 d = self._handle_new_pdu(transaction.origin, pdu)
 
-                def handle_failure(failure):
-                    failure.trap(FederationError)
-                    self.send_failure(failure.value, transaction.origin)
-
-                d.addErrback(handle_failure)
-
-                dl.append(d)
+                try:
+                    yield d
+                    results.append({})
+                except FederationError as e:
+                    self.send_failure(e, transaction.origin)
+                    results.append({"error": str(e)})
+                except Exception as e:
+                    results.append({"error": str(e)})
+                    logger.exception("Failed to handle PDU")
 
             if hasattr(transaction, "edus"):
                 for edu in [Edu(**x) for x in transaction.edus]:
@@ -135,29 +138,11 @@ class FederationServer(FederationBase):
             for failure in getattr(transaction, "pdu_failures", []):
                 logger.info("Got failure %r", failure)
 
-            results = yield defer.DeferredList(dl, consumeErrors=True)
-
-        ret = []
-        for r in results:
-            if r[0]:
-                ret.append({})
-            else:
-                failure = r[1]
-                logger.error(
-                    "Failed to handle PDU",
-                    exc_info=(
-                        failure.type,
-                        failure.value,
-                        failure.getTracebackObject()
-                    )
-                )
-                ret.append({"error": str(r[1].value)})
-
-        logger.debug("Returning: %s", str(ret))
+        logger.debug("Returning: %s", str(results))
 
         response = {
             "pdus": dict(zip(
-                (p.event_id for p in pdu_list), ret
+                (p.event_id for p in pdu_list), results
             )),
         }