slightly faster and thread safer inference

This commit is contained in:
Miroslav Stampar
2011-01-16 10:52:42 +00:00
parent fb166e9445
commit 71391874eb
7 changed files with 27 additions and 35 deletions

View File

@@ -2080,10 +2080,11 @@ def getComparePageRatio(firstPage, secondPage, filtered=False):
if filtered:
(firstPage, secondPage) = map(getFilteredPageContent, (firstPage, secondPage))
conf.seqMatcher.set_seq1(firstPage)
conf.seqMatcher.set_seq2(secondPage)
seqMatcher = getCurrentThreadData().seqMatcher
seqMatcher.set_seq1(firstPage)
seqMatcher.set_seq2(secondPage)
return conf.seqMatcher.quick_ratio()
return seqMatcher.quick_ratio()
def openFile(filename, mode='r'):
"""

View File

@@ -1077,8 +1077,6 @@ def __setConfAttributes():
conf.port = None
conf.redirectHandled = False
conf.scheme = None
#conf.seqMatcher = difflib.SequenceMatcher(lambda x: x in " \t")
conf.seqMatcher = difflib.SequenceMatcher(None)
conf.sessionFP = None
conf.start = True
conf.tests = []
@@ -1135,7 +1133,6 @@ def __setKnowledgeBaseAttributes(flushAll=True):
kb.locks = advancedDict()
kb.locks.cacheLock = threading.Lock()
kb.locks.logLock = threading.Lock()
kb.locks.seqLock = None
kb.matchRatio = None
kb.nullConnection = None

View File

@@ -7,6 +7,7 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/)
See the file 'doc/COPYING' for copying permission
"""
import difflib
import threading
from lib.core.data import kb
@@ -17,12 +18,13 @@ class ThreadData():
"""
def __init__(self):
self.disableStdOut = False
self.lastErrorPage = None
self.lastHTTPError = None
self.lastQueryDuration = 0
self.lastRequestUID = 0
self.valueStack = []
self.disableStdOut = False
self.lastErrorPage = None
self.lastHTTPError = None
self.lastQueryDuration = 0
self.lastRequestUID = 0
self.seqMatcher = difflib.SequenceMatcher(None)
self.valueStack = []
def getCurrentThreadUID():
return hash(threading.currentThread())