Skip to content

Commit

Permalink
Fix: use tokio interval instead of std sleep
Browse files Browse the repository at this point in the history
In case of using async, std sleep is blocking. So it is better to use tokio time instead
  • Loading branch information
Kraemii committed Mar 6, 2024
1 parent 22215d6 commit 40e9f9d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions rust/openvasd/src/controller/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ where
S: Scanner + 'static + std::marker::Send + std::marker::Sync,
DB: crate::storage::Storage + 'static + std::marker::Send + std::marker::Sync,
{
let interval = ctx.scheduler.config().check_interval;
let mut interval = tokio::time::interval(ctx.scheduler.config().check_interval);
tracing::debug!("Starting synchronization loop");
let mut warn = true;
loop {
interval.tick().await;
if *ctx.abort.read().unwrap() {
tracing::trace!("aborting");
break;
Expand All @@ -42,7 +43,5 @@ where
}
}
}

std::thread::sleep(interval);
}
}

0 comments on commit 40e9f9d

Please sign in to comment.