diff --git a/lib/core/threads.py b/lib/core/threads.py index 8cc58267c..2fc5db15a 100644 --- a/lib/core/threads.py +++ b/lib/core/threads.py @@ -14,6 +14,7 @@ import traceback from thread import error as threadError +from lib.core.data import conf from lib.core.data import kb from lib.core.data import logger from lib.core.datatype import AttribDict @@ -180,5 +181,7 @@ def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardExceptio kb.threadContinue = True kb.threadException = False + conf.hashDB.flush() + if cleanupFunction: cleanupFunction() diff --git a/lib/utils/hashdb.py b/lib/utils/hashdb.py index 13bf1beef..51ec96652 100644 --- a/lib/utils/hashdb.py +++ b/lib/utils/hashdb.py @@ -76,6 +76,9 @@ class HashDB(object): self.flush() def flush(self): + if not self._write_cache: + return + self._cache_lock.acquire() items = self._write_cache.items() self._write_cache.clear()