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()
def tryHint(idx):
hintlock.acquire()
hintValue = kb.hintValue
hintlock.release()
with hintlock:
hintValue = kb.hintValue
if hintValue is not None and len(hintValue) >= idx:
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:
return hintValue[idx-1]
hintlock.acquire()
kb.hintValue = None
hintlock.release()
with hintlock:
kb.hintValue = None
return None
@ -373,10 +371,9 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
else:
break
kb.locks.value.acquire()
threadData.shared.value[curidx - 1] = val
currentValue = list(threadData.shared.value)
kb.locks.value.release()
with kb.locks.value:
threadData.shared.value[curidx - 1] = val
currentValue = list(threadData.shared.value)
if kb.threadContinue:
if showEta:

View File

@ -333,13 +333,11 @@ def errorUse(expression, expected=None, dump=False):
threadData = getCurrentThreadData()
while kb.threadContinue:
kb.locks.limits.acquire()
try:
num = threadData.shared.limits.next()
except StopIteration:
break
finally:
kb.locks.limits.release()
with kb.locks.limits:
try:
num = threadData.shared.limits.next()
except StopIteration:
break
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:
output = output[0]
kb.locks.outputs.acquire()
threadData.shared.outputs.append(output)
kb.locks.outputs.release()
with kb.locks.outputs:
threadData.shared.outputs.append(output)
runThreads(numThreads, errorThread)

View File

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