Skip to content

Commit

Permalink
fix daemon/interactive/onshot modes
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Kennedy committed Mar 23, 2024
1 parent ddb0fe3 commit b7b0dd6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,12 @@ async fn main() {

// break the loop if we are not running as a daemon or hit max iterations
let rctrlc_clone = running_ctrlc.clone();
if (!rctrlc_clone.load(Ordering::SeqCst) || (!args.daemon && args.max_iterations <= 1))
|| (args.max_iterations > 1 && args.max_iterations == iterations)
if (!rctrlc_clone.load(Ordering::SeqCst)
|| (!args.daemon && !args.interactive && args.max_iterations <= iterations))
|| (!args.daemon
&& !args.interactive
&& args.max_iterations > 1
&& args.max_iterations > iterations)
{
// stop the running threads
if args.ai_network_stats {
Expand Down Expand Up @@ -748,7 +752,11 @@ async fn main() {
let elapsed = poll_start_time.elapsed();

// Sleep only if the elapsed time is less than the poll interval
if elapsed < poll_interval_duration {
if iterations > 0
&& !args.interactive
&& (args.daemon || args.max_iterations > 1)
&& elapsed < poll_interval_duration
{
// Sleep only if the elapsed time is less than the poll interval
println!(
"Finished loop #{} Sleeping for {} ms...",
Expand Down

0 comments on commit b7b0dd6

Please sign in to comment.