mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 21:19:31 +01:00
relay: attempt to fix race conditions in getRemoteUser calls (#92)
This commit is contained in:
parent
13e4baba8b
commit
65b8c9db8a
@ -16,7 +16,9 @@ dbname = "pylinkrelay"
|
|||||||
if confname != 'pylink':
|
if confname != 'pylink':
|
||||||
dbname += '-%s' % confname
|
dbname += '-%s' % confname
|
||||||
dbname += '.db'
|
dbname += '.db'
|
||||||
|
|
||||||
relayusers = defaultdict(dict)
|
relayusers = defaultdict(dict)
|
||||||
|
spawnlocks = defaultdict(threading.Lock)
|
||||||
|
|
||||||
def relayWhoisHandlers(irc, target):
|
def relayWhoisHandlers(irc, target):
|
||||||
user = irc.users[target]
|
user = irc.users[target]
|
||||||
@ -124,6 +126,7 @@ def getRemoteUser(irc, remoteirc, user, spawnIfMissing=True):
|
|||||||
return remoteirc.pseudoclient.uid
|
return remoteirc.pseudoclient.uid
|
||||||
except AttributeError: # Network hasn't been initialized yet?
|
except AttributeError: # Network hasn't been initialized yet?
|
||||||
pass
|
pass
|
||||||
|
with spawnlocks[irc.name]:
|
||||||
try:
|
try:
|
||||||
u = relayusers[(irc.name, user)][remoteirc.name]
|
u = relayusers[(irc.name, user)][remoteirc.name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
Loading…
Reference in New Issue
Block a user