3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-02-17 14:01:03 +01:00

relay: bandaid patch for freezes on startup when there are a ton of networks

The side effect of this patch is that it makes large bursts *really* CPU intensive. A proper fix for this will hopefully be introduced in the future.
This commit is contained in:
James Lu 2018-03-11 21:26:37 -07:00
parent b7b49769e0
commit 5bffe67416

View File

@ -33,10 +33,7 @@ default_permissions = {"*!*@*": ['relay.linked'],
def initialize_all(irc):
"""Initializes all relay channels for the given IRC object."""
# Wait for all IRC objects to be created first. This prevents
# relay servers from being spawned too early (before server authentication),
# which would break connections.
if world.started.wait(TCONDITION_TIMEOUT):
def _initialize_all():
for chanpair, entrydata in db.items():
network, channel = chanpair
@ -48,6 +45,14 @@ def initialize_all(irc):
if network == irc.name:
initialize_channel(irc, channel)
# Wait for all IRC objects to be created first. This prevents
# relay servers from being spawned too early (before server authentication),
# which would break connections.
if world.started.wait(TCONDITION_TIMEOUT):
t = threading.Thread(target=_initialize_all, daemon=True,
name='relay initialize_all thread from network %r' % irc.name)
t.start()
def main(irc=None):
"""Main function, called during plugin loading at start."""
log.debug('relay.main: loading links database')
@ -500,9 +505,8 @@ def initialize_channel(irc, channel):
# from the config. Skip this.
continue
# Give each network a tiny bit of leeway to finish up its connection.
# This is better than just dropping users their completely.
if not remoteirc.connected.wait(TCONDITION_TIMEOUT):
# Remote net isn't ready yet, try again later.
if not remoteirc.connected.is_set():
continue
# Join their (remote) users and set their modes, if applicable.