From de55ba218f6f7a67684e09f34153476e2274e341 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Sat, 6 Sep 2014 17:38:11 +0100 Subject: [PATCH] Fix race in presence handler where we evicted things from cache while handling a key therein --- synapse/handlers/presence.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index c79bb6ff7..b2af09f09 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -796,11 +796,12 @@ class PresenceEventSource(object): updates = [] # TODO(paul): use a DeferredList ? How to limit concurrency. for observed_user in cachemap.keys(): - if not (from_key < cachemap[observed_user].serial): + cached = cachemap[observed_user] + if not (from_key < cached.serial): continue if (yield self.is_visible(observer_user, observed_user)): - updates.append((observed_user, cachemap[observed_user])) + updates.append((observed_user, cached)) # TODO(paul): limit