diff options
author | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-04-23 18:40:47 +0100 |
---|---|---|
committer | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-04-23 18:40:47 +0100 |
commit | b3bda8a75f9745fd351d2c2093ffc68774e8a2e2 (patch) | |
tree | 10f927996ef62c617fc3675209e2223cdfaaf565 | |
parent | Store a list of the presence serial number at which remote users went offline... (diff) | |
download | synapse-b3bda8a75f9745fd351d2c2093ffc68774e8a2e2.tar.xz |
Don't let the remote offline serial list grow arbitrarily large
Diffstat (limited to '')
-rw-r--r-- | synapse/handlers/presence.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index 42fb622c48..f929bcf853 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -36,6 +36,9 @@ metrics = synapse.metrics.get_metrics_for(__name__) # Don't bother bumping "last active" time if it differs by less than 60 seconds LAST_ACTIVE_GRANULARITY = 60*1000 +# Keep no more than this number of offline serial revisions +MAX_OFFLINE_SERIALS = 1000 + # TODO(paul): Maybe there's one of these I can steal from somewhere def partition(l, func): @@ -722,6 +725,8 @@ class PresenceHandler(BaseHandler): 0, (self._user_cachemap_latest_serial, set([user.to_string()])) ) + while len(self._remote_offline_serials) > MAX_OFFLINE_SERIALS: + self._remote_offline_serials.pop() # remove the oldest del self._user_cachemap[user] for poll in content.get("poll", []): |