Fixes #378: must acquire JID_CACHE_LOCK before adding to JID_CACHE

This commit is contained in:
Michele Cella 2015-07-31 11:55:50 +02:00
parent bb094cc649
commit f54ebec654

View File

@ -72,9 +72,8 @@ JID_CACHE_LOCK = threading.Lock()
JID_CACHE_MAX_SIZE = 1024
def _cache(key, parts, locked):
JID_CACHE[key] = (parts, locked)
if len(JID_CACHE) > JID_CACHE_MAX_SIZE:
with JID_CACHE_LOCK:
JID_CACHE[key] = (parts, locked)
while len(JID_CACHE) > JID_CACHE_MAX_SIZE:
found = None
for key, item in JID_CACHE.items():