Skip to content

Commit

Permalink
fix(tracer): off-by-one bug in Tracer::finished (#906)
Browse files Browse the repository at this point in the history
This bug causes the tracer to run for `max_rounds + 1` rounds.  This bug is does
not impact reports which terminate after the correct number of rounds and exit
the process and thus stopping the `tracer` thread.  This bug is observed when
using the tracer programatically and setting `max_rounds`.
  • Loading branch information
fujiapple852 committed Jan 4, 2024
1 parent 1633019 commit 934d3c0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
3 changes: 0 additions & 3 deletions src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use crate::backend::trace::Trace;
use anyhow::anyhow;
use parking_lot::RwLock;
use std::sync::Arc;
use std::thread::sleep;
use std::time::Duration;

pub mod csv;
pub mod dot;
Expand All @@ -24,7 +22,6 @@ fn wait_for_round(trace_data: &Arc<RwLock<Trace>>, report_cycles: usize) -> anyh
if let Some(err) = trace.error() {
return Err(anyhow!("error: {}", err));
}
sleep(Duration::from_millis(100));
}
Ok(trace)
}
2 changes: 1 addition & 1 deletion src/tracing/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ mod state {
pub fn finished(&self, max_rounds: Option<MaxRounds>) -> bool {
match max_rounds {
None => false,
Some(max_rounds) => self.round.0 > max_rounds.0,
Some(max_rounds) => self.round.0 > max_rounds.0 - 1,
}
}

Expand Down

0 comments on commit 934d3c0

Please sign in to comment.