diff options
author | David Baker <dave@matrix.org> | 2016-04-29 10:05:20 +0100 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2016-04-29 10:05:20 +0100 |
commit | acded821c4ff9da11ce7f916ca8b0f369bcb4e87 (patch) | |
tree | 6a797cfae11a8cf64277ff878c090d7905db9d19 /synapse/state.py | |
parent | Remove vector specific style (diff) | |
parent | Fix more typos in per-request metrics (diff) | |
download | synapse-acded821c4ff9da11ce7f916ca8b0f369bcb4e87.tar.xz |
Merge remote-tracking branch 'origin/develop' into dbkr/email_notifs
Diffstat (limited to 'synapse/state.py')
-rw-r--r-- | synapse/state.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/synapse/state.py b/synapse/state.py index 58211f5feb..d0f76dc4f5 100644 --- a/synapse/state.py +++ b/synapse/state.py @@ -214,7 +214,7 @@ class StateHandler(object): if self._state_cache is not None: cache = self._state_cache.get(group_names, None) - if cache and cache.state_group: + if cache: cache.ts = self.clock.time_msec() event_dict = yield self.store.get_events(cache.state.values()) @@ -230,22 +230,34 @@ class StateHandler(object): (cache.state_group, state, prev_states) ) + logger.info("Resolving state for %s with %d groups", room_id, len(state_groups)) + new_state, prev_states = self._resolve_events( state_groups.values(), event_type, state_key ) + state_group = None + new_state_event_ids = frozenset(e.event_id for e in new_state.values()) + for sg, events in state_groups.items(): + if new_state_event_ids == frozenset(e.event_id for e in events): + state_group = sg + break + if self._state_cache is not None: cache = _StateCacheEntry( state={key: event.event_id for key, event in new_state.items()}, - state_group=None, + state_group=state_group, ts=self.clock.time_msec() ) self._state_cache[group_names] = cache - defer.returnValue((None, new_state, prev_states)) + defer.returnValue((state_group, new_state, prev_states)) def resolve_events(self, state_sets, event): + logger.info( + "Resolving state for %s with %d groups", event.room_id, len(state_sets) + ) if event.is_state(): return self._resolve_events( state_sets, event.type, event.state_key |