summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2020-05-22 21:47:07 +0100
committerGitHub <noreply@github.com>2020-05-22 21:47:07 +0100
commitf4269694ce51a04761e43fc5897d6f8fe0ea18cc (patch)
treed75ac87e2a6488399201e8680afed757e2131750 /synapse/handlers
parentFix missing CORS headers on OPTION responses (#7560) (diff)
downloadsynapse-f4269694ce51a04761e43fc5897d6f8fe0ea18cc.tar.xz
Optimise some references to hs.config (#7546)
These are surprisingly expensive, and we only really need to do them at startup.
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/message.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index ea25f0515a..681f92cafd 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -366,7 +366,9 @@ class EventCreationHandler(object):
         self.notifier = hs.get_notifier()
         self.config = hs.config
         self.require_membership_for_aliases = hs.config.require_membership_for_aliases
-        self._instance_name = hs.get_instance_name()
+        self._is_event_writer = (
+            self.config.worker.writers.events == hs.get_instance_name()
+        )
 
         self.room_invite_state_types = self.hs.config.room_invite_state_types
 
@@ -836,7 +838,7 @@ class EventCreationHandler(object):
         success = False
         try:
             # If we're a worker we need to hit out to the master.
-            if self.config.worker.writers.events != self._instance_name:
+            if not self._is_event_writer:
                 result = await self.send_event(
                     instance_name=self.config.worker.writers.events,
                     event_id=event.event_id,
@@ -906,7 +908,7 @@ class EventCreationHandler(object):
 
         This should only be run on the instance in charge of persisting events.
         """
-        assert self.config.worker.writers.events == self._instance_name
+        assert self._is_event_writer
 
         if ratelimit:
             # We check if this is a room admin redacting an event so that we