mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-17 07:21:37 +01:00
Fix a race between started/stopped stream
This commit is contained in:
parent
8505a4ddc3
commit
dbe7892e03
1 changed files with 8 additions and 3 deletions
|
@ -69,7 +69,12 @@ class EventStreamHandler(BaseHandler):
|
||||||
A deferred that completes once their presence has been updated.
|
A deferred that completes once their presence has been updated.
|
||||||
"""
|
"""
|
||||||
if user not in self._streams_per_user:
|
if user not in self._streams_per_user:
|
||||||
self._streams_per_user[user] = 0
|
# Make sure we set the streams per user to 1 here rather than
|
||||||
|
# setting it to zero and incrementing the value below.
|
||||||
|
# Otherwise this may race with stopped_stream causing the
|
||||||
|
# user to be erased from the map before we have a chance
|
||||||
|
# to increment it.
|
||||||
|
self._streams_per_user[user] = 1
|
||||||
if user in self._stop_timer_per_user:
|
if user in self._stop_timer_per_user:
|
||||||
try:
|
try:
|
||||||
self.clock.cancel_call_later(
|
self.clock.cancel_call_later(
|
||||||
|
@ -79,7 +84,7 @@ class EventStreamHandler(BaseHandler):
|
||||||
logger.exception("Failed to cancel event timer")
|
logger.exception("Failed to cancel event timer")
|
||||||
else:
|
else:
|
||||||
yield started_user_eventstream(self.distributor, user)
|
yield started_user_eventstream(self.distributor, user)
|
||||||
|
else:
|
||||||
self._streams_per_user[user] += 1
|
self._streams_per_user[user] += 1
|
||||||
|
|
||||||
def stopped_stream(self, user):
|
def stopped_stream(self, user):
|
||||||
|
|
Loading…
Reference in a new issue