3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-23 19:19:31 +01:00

relay: use two locks (one for clients, one for servers) to prevent lock ups on start

This commit is contained in:
James Lu 2015-09-20 16:56:24 -07:00
parent 16d8a2212a
commit f2b6d1a3ad

View File

@ -23,6 +23,7 @@ dbname += '.db'
relayusers = defaultdict(dict)
relayservers = defaultdict(dict)
spawnlocks = defaultdict(threading.RLock)
spawnlocks_servers = defaultdict(threading.RLock)
savecache = ExpiringDict(max_len=5, max_age_seconds=10)
killcache = ExpiringDict(max_len=5, max_age_seconds=10)
@ -143,7 +144,7 @@ def getPrefixModes(irc, remoteirc, channel, user, mlist=None):
def getRemoteSid(irc, remoteirc):
"""Gets the remote server SID representing remoteirc on irc, spawning
it if it doesn't exist."""
with spawnlocks[irc.name]:
with spawnlocks_servers[irc.name]:
try:
sid = relayservers[irc.name][remoteirc.name]
except KeyError: