Fix race condition while iterating over clients
This commit is contained in:
parent
176775f8f3
commit
8d97227965
|
@ -114,6 +114,7 @@ def moderated(fro, chan, message):
|
||||||
def kickAll(fro, chan, message):
|
def kickAll(fro, chan, message):
|
||||||
# Kick everyone but mods/admins
|
# Kick everyone but mods/admins
|
||||||
toKick = []
|
toKick = []
|
||||||
|
with glob.tokens:
|
||||||
for key, value in glob.tokens.tokens.items():
|
for key, value in glob.tokens.tokens.items():
|
||||||
if not value.admin:
|
if not value.admin:
|
||||||
toKick.append(key)
|
toKick.append(key)
|
||||||
|
@ -336,6 +337,7 @@ def systemMaintenance(fro, chan, message):
|
||||||
who = []
|
who = []
|
||||||
|
|
||||||
# Disconnect everyone but mod/admins
|
# Disconnect everyone but mod/admins
|
||||||
|
with glob.tokens:
|
||||||
for _, value in glob.tokens.tokens.items():
|
for _, value in glob.tokens.tokens.items():
|
||||||
if not value.admin:
|
if not value.admin:
|
||||||
who.append(value.userID)
|
who.append(value.userID)
|
||||||
|
|
|
@ -184,6 +184,7 @@ def handle(tornadoRequest):
|
||||||
responseToken.enqueue(serverPackets.mainMenuIcon(glob.banchoConf.config["menuIcon"]))
|
responseToken.enqueue(serverPackets.mainMenuIcon(glob.banchoConf.config["menuIcon"]))
|
||||||
|
|
||||||
# Send online users' panels
|
# Send online users' panels
|
||||||
|
with glob.tokens:
|
||||||
for _, token in glob.tokens.tokens.items():
|
for _, token in glob.tokens.tokens.items():
|
||||||
if not token.restricted:
|
if not token.restricted:
|
||||||
responseToken.enqueue(serverPackets.userPanel(token.userID))
|
responseToken.enqueue(serverPackets.userPanel(token.userID))
|
||||||
|
|
|
@ -13,6 +13,13 @@ from objects import osuToken
|
||||||
class tokenList:
|
class tokenList:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.tokens = {}
|
self.tokens = {}
|
||||||
|
self._lock = threading.Lock()
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
self._lock.acquire()
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
|
self._lock.release()
|
||||||
|
|
||||||
def addToken(self, userID, ip = "", irc = False, timeOffset=0, tournament=False):
|
def addToken(self, userID, ip = "", irc = False, timeOffset=0, tournament=False):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user