Pre-prime the first list of CONCURRENCY_LIMIT threads, and bail out

early if there are none to be run. This avoids printing
ScanProgressMeter messages.
This commit is contained in:
david 2011-01-08 07:20:40 +00:00
parent 1392faf5d4
commit 9857411032

View file

@ -634,7 +634,6 @@ local function run (threads_iter, scantype)
local current; -- The currently running Thread.
local total = 0; -- Number of threads, for record keeping.
local timeouts = {}; -- A list to save and to track scripts timeout.
local progress = cnse.scan_progress_meter(NAME);
local num_threads = 0; -- Number of script instances currently running.
-- Map of yielded threads to the base Thread
@ -708,6 +707,22 @@ local function run (threads_iter, scantype)
return current.co;
end);
while threads_iter and num_threads < CONCURRENCY_LIMIT do
local thread = threads_iter()
if not thread then
threads_iter = nil;
break;
end
all[thread.co], running[thread.co], total = thread, thread, total+1;
num_threads = num_threads + 1;
thread:start(timeouts);
end
if num_threads == 0 then
return
end
local progress = cnse.scan_progress_meter(NAME);
-- Loop while any thread is running or waiting.
while next(running) or next(waiting) or threads_iter do
-- Start as many new threads as possible.