mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-07 21:21:33 +00:00
some refactoring
This commit is contained in:
@@ -1773,7 +1773,7 @@ def readCachedFileContent(filename, mode='rb'):
|
||||
"""
|
||||
|
||||
if filename not in kb.cache.content:
|
||||
kb.locks.cacheLock.acquire()
|
||||
kb.locks.cache.acquire()
|
||||
|
||||
if filename not in kb.cache.content:
|
||||
checkFile(filename)
|
||||
@@ -1781,7 +1781,7 @@ def readCachedFileContent(filename, mode='rb'):
|
||||
content = f.read()
|
||||
kb.cache.content[filename] = content
|
||||
|
||||
kb.locks.cacheLock.release()
|
||||
kb.locks.cache.release()
|
||||
|
||||
return kb.cache.content[filename]
|
||||
|
||||
@@ -2241,13 +2241,13 @@ def logHTTPTraffic(requestLogMsg, responseLogMsg):
|
||||
if not conf.trafficFile:
|
||||
return
|
||||
|
||||
kb.locks.logLock.acquire()
|
||||
kb.locks.log.acquire()
|
||||
|
||||
dataToTrafficFile("%s%s" % (requestLogMsg, os.linesep))
|
||||
dataToTrafficFile("%s%s" % (responseLogMsg, os.linesep))
|
||||
dataToTrafficFile("%s%s%s%s" % (os.linesep, 76 * '#', os.linesep, os.linesep))
|
||||
|
||||
kb.locks.logLock.release()
|
||||
kb.locks.log.release()
|
||||
|
||||
def getPageTemplate(payload, place):
|
||||
"""
|
||||
|
||||
@@ -1437,10 +1437,8 @@ def __setKnowledgeBaseAttributes(flushAll=True):
|
||||
kb.lastParserStatus = None
|
||||
|
||||
kb.locks = AttribDict()
|
||||
kb.locks.cacheLock = threading.Lock()
|
||||
kb.locks.logLock = threading.Lock()
|
||||
kb.locks.ioLock = threading.Lock()
|
||||
kb.locks.countLock = threading.Lock()
|
||||
for _ in ("cache", "count", "index", "io", "limits", "log", "outputs", "value"):
|
||||
kb.locks[_] = threading.Lock()
|
||||
|
||||
kb.matchRatio = None
|
||||
kb.multiThreadMode = False
|
||||
|
||||
@@ -188,6 +188,10 @@ def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardExceptio
|
||||
kb.threadContinue = True
|
||||
kb.threadException = False
|
||||
|
||||
for lock in kb.locks.values():
|
||||
if lock.locked_lock():
|
||||
lock.release()
|
||||
|
||||
if conf.get("hashDB", None):
|
||||
conf.hashDB.flush(True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user