summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-28 17:24:24 +0100
committerErik Johnston <erik@matrix.org>2015-04-28 17:24:24 +0100
commit1783c7ca920cdacb22fa8536af03f42557af9d41 (patch)
tree79b1116644544a7dddd45776cac938c6fcc4c9b7 /synapse/handlers
parentFix typo (diff)
downloadsynapse-1783c7ca920cdacb22fa8536af03f42557af9d41.tar.xz
Ensure we never miss any presence updates
Diffstat (limited to '')
-rw-r--r--synapse/handlers/presence.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py
index 47cfe62c82..42cd528908 100644
--- a/synapse/handlers/presence.py
+++ b/synapse/handlers/presence.py
@@ -858,6 +858,9 @@ class PresenceEventSource(object):
 
         presence = self.hs.get_handlers().presence_handler
         cachemap = presence._user_cachemap
+
+        max_serial = presence._user_cachemap_latest_serial
+
         clock = self.clock
         latest_serial = 0
 
@@ -866,7 +869,7 @@ class PresenceEventSource(object):
         for observed_user in cachemap.keys():
             cached = cachemap[observed_user]
 
-            if cached.serial <= from_key:
+            if cached.serial <= from_key or cached.serial > max_serial:
                 continue
 
             if not (yield self.is_visible(observer_user, observed_user)):
@@ -881,6 +884,9 @@ class PresenceEventSource(object):
             if serial < from_key:
                 break
 
+            if serial > max_serial:
+                continue
+
             latest_serial = max(latest_serial, serial)
             for u in user_ids:
                 updates.append({