Skip to content

Commit

Permalink
Add some comments that chain map won't infinitely grow
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Aug 19, 2024
1 parent 5b6755a commit 7f5bccc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions synapse/handlers/sliding_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -3069,6 +3069,9 @@ def copy(self) -> "RoomStatusMap":
class MutableRoomStatusMap(RoomStatusMap):
"""A mutable version of `RoomStatusMap`"""

# We use a ChainMap here so that we can easily track what has been updated
# and what hasn't. Note that when we persist the per connection state this
# will get flattened to a normal dict (via calling `.copy()`)
_statuses: typing.ChainMap[str, HaveSentRoom]

def __init__(
Expand Down Expand Up @@ -3253,6 +3256,8 @@ async def record_new_state(
new_store_token = prev_connection_token + 1
sync_statuses.pop(new_store_token, None)

# We copy the `MutablePerConnectionState` so that the inner `ChainMap`s
# don't grow forever.
sync_statuses[new_store_token] = PerConnectionState(
rooms=per_connection_state.rooms.copy(),
)
Expand Down

0 comments on commit 7f5bccc

Please sign in to comment.