summary refs log tree commit diff
path: root/synapse/server.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-11-23 14:09:47 +0000
committerErik Johnston <erik@matrix.org>2016-11-23 14:09:47 +0000
commit26072df6af7ca37b8e6e5f340a00e695de5c93d5 (patch)
tree2abd7451b4b1ffbef5f8e899f1fed7272e89c193 /synapse/server.py
parentMerge branch 'develop' of github.com:matrix-org/synapse into erikj/split_out_... (diff)
downloadsynapse-26072df6af7ca37b8e6e5f340a00e695de5c93d5.tar.xz
Ensure only main or federation_sender process can send federation traffic
Diffstat (limited to 'synapse/server.py')
-rw-r--r--synapse/server.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/synapse/server.py b/synapse/server.py
index 6c57ab3e18..ef75ab434c 100644
--- a/synapse/server.py
+++ b/synapse/server.py
@@ -274,14 +274,23 @@ class HomeServer(object):
         return TransportLayerClient(self)
 
     def build_federation_sender(self):
-        if self.config.send_federation:
+        if self.should_send_federation():
             return TransactionQueue(self)
-        else:
+        elif not self.config.worker_app:
             return FederationRemoteSendQueue(self)
+        else:
+            raise Exception("Workers cannot send federation traffic")
 
     def remove_pusher(self, app_id, push_key, user_id):
         return self.get_pusherpool().remove_pusher(app_id, push_key, user_id)
 
+    def should_send_federation(self):
+        "Should this server be sending federation traffic directly?"
+        return self.config.send_federation and (
+            not self.config.worker_app
+            or self.config.worker_app == "synapse.app.federation_sender"
+        )
+
 
 def _make_dependency_method(depname):
     def _get(hs):