From fcde4166be532eec80f5d1497c52ad93858e8701 Mon Sep 17 00:00:00 2001 From: dmiller Date: Sat, 10 Mar 2018 03:09:33 +0000 Subject: [PATCH] Don't hang waiting for threads that don't exist if they errored out --- nselib/brute.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/nselib/brute.lua b/nselib/brute.lua index 2a9e012cc..b929c9869 100644 --- a/nselib/brute.lua +++ b/nselib/brute.lua @@ -807,7 +807,7 @@ Engine = { break end - -- Updtae tick and add this thread to the batch + -- Update tick and add this thread to the batch self.tick = self.tick + 1 if not (self.batch:isFull()) and not thread_data.in_batch then @@ -1218,14 +1218,17 @@ Engine = { end + local threads = self:threadCount() stdnse.debug2("Status: #threads = %d, #retry_accounts = %d, initial_accounts_exhausted = %s, waiting = %d", - self:threadCount(), #self.retry_accounts, tostring(self.initial_accounts_exhausted), + threads, #self.retry_accounts, tostring(self.initial_accounts_exhausted), nmap.socket.get_stats().connect_waiting) - -- wake up other threads - -- wait for all threads to finish running - condvar "broadcast" - condvar "wait" + if threads > 0 then + -- wake up other threads + -- wait for all threads to finish running + condvar "broadcast" + condvar "wait" + end end