@@ -154,10 +154,11 @@ def etaProgressUpdate(charTime, index):
154154 idxlock = threading .Lock ()
155155 iolock = threading .Lock ()
156156 conf .seqLock = threading .Lock ()
157+ conf .threadContinue = True
157158
158159 def downloadThread ():
159160 try :
160- while True :
161+ while conf . threadContinue :
161162 idxlock .acquire ()
162163
163164 if index [0 ] >= length :
@@ -169,21 +170,24 @@ def downloadThread():
169170 curidx = index [0 ]
170171 idxlock .release ()
171172
172- charStart = time .time ()
173- val = getChar (curidx )
174-
175- if val is None :
176- raise sqlmapValueException , "failed to get character at index %d (expected %d total)" % (curidx , length )
173+ if conf .threadContinue :
174+ charStart = time .time ()
175+ val = getChar (curidx )
176+ if val is None :
177+ raise sqlmapValueException , "failed to get character at index %d (expected %d total)" % (curidx , length )
178+ else :
179+ break
177180
178181 value [curidx - 1 ] = val
179182
180- if showEta :
181- etaProgressUpdate (time .time () - charStart , index [0 ])
182- elif conf .verbose >= 1 :
183- s = "" .join ([c or "_" for c in value ])
184- iolock .acquire ()
185- dataToStdout ("\r [%s] [INFO] retrieved: %s" % (time .strftime ("%X" ), s ))
186- iolock .release ()
183+ if conf .threadContinue :
184+ if showEta :
185+ etaProgressUpdate (time .time () - charStart , index [0 ])
186+ elif conf .verbose >= 1 :
187+ s = "" .join ([c or "_" for c in value ])
188+ iolock .acquire ()
189+ dataToStdout ("\r [%s] [INFO] retrieved: %s" % (time .strftime ("%X" ), s ))
190+ iolock .release ()
187191
188192 except (sqlmapConnectionException , sqlmapValueException ), errMsg :
189193 conf .threadException = True
@@ -215,9 +219,21 @@ def downloadThread():
215219 threads .append (thread )
216220
217221 # And wait for them to all finish
218- for thread in threads :
219- thread .join ()
220-
222+ #for thread in threads:
223+ # thread.join()
224+
225+ try :
226+ alive = True
227+ while alive :
228+ alive = False
229+ for thread in threads :
230+ if thread .isAlive ():
231+ alive = True
232+ thread .join (5 )
233+ except KeyboardInterrupt :
234+ conf .threadContinue = False
235+ raise
236+
221237 # If we have got one single character not correctly fetched it
222238 # can mean that the connection to the target url was lost
223239 if None in value :
0 commit comments