Major silent bug fix to multi-threading functionality. Thanks Nico Leidecker for reporting!

This commit is contained in:
Bernardo Damele 2009-05-20 09:34:13 +00:00
parent f7ee4d578e
commit 13de8366d0

View File

@ -140,38 +140,34 @@ def bisection(payload, expression, length=None, charsetType=None):
def downloadThread(): def downloadThread():
while True: try:
idxlock.acquire() while True:
idxlock.acquire()
if index[0] >= length: if index[0] >= length:
idxlock.release()
return
index[0] += 1
curidx = index[0]
idxlock.release() idxlock.release()
return charStart = time.time()
val = getChar(curidx)
index[0] += 1 if val == None:
curidx = index[0] raise sqlmapValueException, "failed to get character at index %d (expected %d total)" % (curidx, length)
idxlock.release()
charStart = time.time() value[curidx-1] = val
val = getChar(curidx)
if val == None: if showEta:
raise sqlmapValueException, "failed to get character at index %d (expected %d total)" % (curidx, length) etaProgressUpdate(time.time() - charStart, index[0])
elif conf.verbose in ( 1, 2 ):
value[curidx-1] = val s = "".join([c or "_" for c in value])
iolock.acquire()
if showEta: dataToStdout("\r[%s] [INFO] retrieved: %s" % (time.strftime("%X"), s))
etaProgressUpdate(time.time() - charStart, index[0]) iolock.release()
elif conf.verbose in ( 1, 2 ):
s = "".join([c or "_" for c in value])
iolock.acquire()
dataToStdout("\r[%s] [INFO] retrieved: %s" % (time.strftime("%X"), s))
iolock.release()
def downloadThreadProxy(numThread):
try:
downloadThread()
except (sqlmapConnectionException, sqlmapValueException), errMsg: except (sqlmapConnectionException, sqlmapValueException), errMsg:
conf.threadException = True conf.threadException = True
@ -199,7 +195,7 @@ def bisection(payload, expression, length=None, charsetType=None):
# Start the threads # Start the threads
for numThread in range(numThreads): for numThread in range(numThreads):
thread = threading.Thread(target=downloadThreadProxy(numThread)) thread = threading.Thread(target=downloadThread)
thread.start() thread.start()
threads.append(thread) threads.append(thread)