From 3edd2d5c93ccbec46f101e65c6c7874a90bf0018 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Thu, 14 May 2015 11:25:30 +0100 Subject: [PATCH] Fix v2 sync, update the last_notified_ms only if there was an active listener --- synapse/handlers/sync.py | 2 +- synapse/notifier.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py index 35a62fda4..bd8c60368 100644 --- a/synapse/handlers/sync.py +++ b/synapse/handlers/sync.py @@ -92,7 +92,7 @@ class SyncHandler(BaseHandler): result = yield self.current_sync_for_user(sync_config, since_token) defer.returnValue(result) else: - def current_sync_callback(): + def current_sync_callback(before_token, after_token): return self.current_sync_for_user(sync_config, since_token) rm_handler = self.hs.get_handlers().room_member_handler diff --git a/synapse/notifier.py b/synapse/notifier.py index 1f7f0a143..2de7dca8a 100644 --- a/synapse/notifier.py +++ b/synapse/notifier.py @@ -81,14 +81,15 @@ class _NotifierUserStream(object): self.last_notified_ms = time_now_ms def notify(self, stream_key, stream_id, time_now_ms): - self.last_notified_ms = time_now_ms self.current_token = self.current_token.copy_and_replace( stream_key, stream_id ) - listeners = self.listeners - self.listeners = set() - for listener in listeners: - listener.notify(self.current_token) + if self.listeners: + self.last_notified_ms = time_now_ms + listeners = self.listeners + self.listeners = set() + for listener in listeners: + listener.notify(self.current_token) def remove(self, notifier): """ Remove this listener from all the indexes in the Notifier