mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Merge pull request #102 from matrix-org/randomize_stream_timeout
Add some randomness to the user specified timeout on event streams to mi...
This commit is contained in:
commit
e780492ecf
@ -23,6 +23,7 @@ from synapse.events.utils import serialize_event
|
|||||||
from ._base import BaseHandler
|
from ._base import BaseHandler
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -72,6 +73,14 @@ class EventStreamHandler(BaseHandler):
|
|||||||
rm_handler = self.hs.get_handlers().room_member_handler
|
rm_handler = self.hs.get_handlers().room_member_handler
|
||||||
room_ids = yield rm_handler.get_rooms_for_user(auth_user)
|
room_ids = yield rm_handler.get_rooms_for_user(auth_user)
|
||||||
|
|
||||||
|
if timeout:
|
||||||
|
# If they've set a timeout set a minimum limit.
|
||||||
|
timeout = max(timeout, 500)
|
||||||
|
|
||||||
|
# Add some randomness to this value to try and mitigate against
|
||||||
|
# thundering herds on restart.
|
||||||
|
timeout = random.randint(int(timeout*0.9), int(timeout*1.1))
|
||||||
|
|
||||||
with PreserveLoggingContext():
|
with PreserveLoggingContext():
|
||||||
events, tokens = yield self.notifier.get_events_for(
|
events, tokens = yield self.notifier.get_events_for(
|
||||||
auth_user, room_ids, pagin_config, timeout
|
auth_user, room_ids, pagin_config, timeout
|
||||||
|
Loading…
Reference in New Issue
Block a user