some more cleanup

This commit is contained in:
Miroslav Stampar 2012-06-14 13:50:36 +00:00
parent d5e80089ff
commit facce2c0df
3 changed files with 22 additions and 31 deletions

View File

@ -147,9 +147,8 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
hintlock = threading.Lock() hintlock = threading.Lock()
def tryHint(idx): def tryHint(idx):
hintlock.acquire() with hintlock:
hintValue = kb.hintValue hintValue = kb.hintValue
hintlock.release()
if hintValue is not None and len(hintValue) >= idx: if hintValue is not None and len(hintValue) >= idx:
if Backend.getIdentifiedDbms() in (DBMS.SQLITE, DBMS.ACCESS, DBMS.MAXDB, DBMS.DB2): if Backend.getIdentifiedDbms() in (DBMS.SQLITE, DBMS.ACCESS, DBMS.MAXDB, DBMS.DB2):
@ -164,9 +163,8 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
if result: if result:
return hintValue[idx-1] return hintValue[idx-1]
hintlock.acquire() with hintlock:
kb.hintValue = None kb.hintValue = None
hintlock.release()
return None return None
@ -373,10 +371,9 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
else: else:
break break
kb.locks.value.acquire() with kb.locks.value:
threadData.shared.value[curidx - 1] = val threadData.shared.value[curidx - 1] = val
currentValue = list(threadData.shared.value) currentValue = list(threadData.shared.value)
kb.locks.value.release()
if kb.threadContinue: if kb.threadContinue:
if showEta: if showEta:

View File

@ -333,13 +333,11 @@ def errorUse(expression, expected=None, dump=False):
threadData = getCurrentThreadData() threadData = getCurrentThreadData()
while kb.threadContinue: while kb.threadContinue:
kb.locks.limits.acquire() with kb.locks.limits:
try: try:
num = threadData.shared.limits.next() num = threadData.shared.limits.next()
except StopIteration: except StopIteration:
break break
finally:
kb.locks.limits.release()
output = __errorFields(expression, expressionFields, expressionFieldsList, expected, num) output = __errorFields(expression, expressionFields, expressionFieldsList, expected, num)
@ -349,9 +347,8 @@ def errorUse(expression, expected=None, dump=False):
if output and isinstance(output, list) and len(output) == 1: if output and isinstance(output, list) and len(output) == 1:
output = output[0] output = output[0]
kb.locks.outputs.acquire() with kb.locks.outputs:
threadData.shared.outputs.append(output) threadData.shared.outputs.append(output)
kb.locks.outputs.release()
runThreads(numThreads, errorThread) runThreads(numThreads, errorThread)

View File

@ -283,13 +283,11 @@ def unionUse(expression, unpack=True, dump=False):
threadData = getCurrentThreadData() threadData = getCurrentThreadData()
while kb.threadContinue: while kb.threadContinue:
kb.locks.limits.acquire() with kb.locks.limits:
try: try:
num = threadData.shared.limits.next() num = threadData.shared.limits.next()
except StopIteration: except StopIteration:
break break
finally:
kb.locks.limits.release()
if Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE): if Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE):
field = expressionFieldsList[0] field = expressionFieldsList[0]
@ -309,10 +307,9 @@ def unionUse(expression, unpack=True, dump=False):
items = parseUnionPage(output) items = parseUnionPage(output)
if isNoneValue(items): if isNoneValue(items):
continue continue
kb.locks.value.acquire() with kb.locks.value:
for item in arrayizeValue(items): for item in arrayizeValue(items):
threadData.shared.value.append(item) threadData.shared.value.append(item)
kb.locks.value.release()
else: else:
items = output.replace(kb.chars.start, "").replace(kb.chars.stop, "").split(kb.chars.delimiter) items = output.replace(kb.chars.start, "").replace(kb.chars.stop, "").split(kb.chars.delimiter)