From bdd0447ea21a843508017fe4952ca9e0d5d7eef0 Mon Sep 17 00:00:00 2001 From: epi Date: Fri, 2 Feb 2024 06:53:26 -0500 Subject: [PATCH] parallel time limit enforced individually instead of main thread --- src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index ceb95e88..f365fd37 100644 --- a/src/main.rs +++ b/src/main.rs @@ -325,9 +325,15 @@ async fn wrapped_main(config: Arc) -> Result<()> { // create new Tasks object, each of these handles is one that will be joined on later let tasks = Tasks::new(out_task, stats_task, filters_task, scan_task); - if !config.time_limit.is_empty() { + if !config.time_limit.is_empty() && config.parallel == 0 { // --time-limit value not an empty string, need to kick off the thread that enforces // the limit + // + // if --parallel is used, this branch won't execute in the main process, but will in the + // children. This is because --parallel is stripped from the children's command line + // arguments, so, when spawned, they won't have --parallel, the parallel value will be set + // to the default of 0, and will hit this branch. This makes it so that the time limit + // is enforced on each individual child process, instead of the main process let time_handles = handles.clone(); tokio::spawn(async move { scan_manager::start_max_time_thread(time_handles).await }); }