Fixes #378: must acquire JID_CACHE_LOCK before adding to JID_CACHE
This commit is contained in:
parent
bb094cc649
commit
f54ebec654
@ -72,19 +72,18 @@ JID_CACHE_LOCK = threading.Lock()
|
|||||||
JID_CACHE_MAX_SIZE = 1024
|
JID_CACHE_MAX_SIZE = 1024
|
||||||
|
|
||||||
def _cache(key, parts, locked):
|
def _cache(key, parts, locked):
|
||||||
JID_CACHE[key] = (parts, locked)
|
with JID_CACHE_LOCK:
|
||||||
if len(JID_CACHE) > JID_CACHE_MAX_SIZE:
|
JID_CACHE[key] = (parts, locked)
|
||||||
with JID_CACHE_LOCK:
|
while len(JID_CACHE) > JID_CACHE_MAX_SIZE:
|
||||||
while len(JID_CACHE) > JID_CACHE_MAX_SIZE:
|
found = None
|
||||||
found = None
|
for key, item in JID_CACHE.items():
|
||||||
for key, item in JID_CACHE.items():
|
if not item[1]: # if not locked
|
||||||
if not item[1]: # if not locked
|
found = key
|
||||||
found = key
|
|
||||||
break
|
|
||||||
if not found: # more than MAX_SIZE locked
|
|
||||||
# warn?
|
|
||||||
break
|
break
|
||||||
del JID_CACHE[found]
|
if not found: # more than MAX_SIZE locked
|
||||||
|
# warn?
|
||||||
|
break
|
||||||
|
del JID_CACHE[found]
|
||||||
|
|
||||||
# pylint: disable=c0103
|
# pylint: disable=c0103
|
||||||
#: The nodeprep profile of stringprep used to validate the local,
|
#: The nodeprep profile of stringprep used to validate the local,
|
||||||
|
Loading…
Reference in New Issue
Block a user