Skip to content

Commit

Permalink
Add a timeout message (#809)
Browse files Browse the repository at this point in the history
To distinguish between errors where an auto-splitter update took too long, from other errors, such as panics, running out of stack space, etc.
  • Loading branch information
AlexKnauth authored Nov 17, 2024
1 parent 47a2b51 commit d35ff05
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/auto_splitting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,7 @@ fn run<T: event::CommandSink + TimerQuery + Send>(

fn watchdog<T: event::CommandSink + TimerQuery + Send>(shared_state: Arc<SharedState<T>>) {
const TIMEOUT: Duration = Duration::from_secs(5);
let mut has_timed_out = false;

let Ok(mut state) = shared_state.watchdog_state.lock() else {
return;
Expand All @@ -944,9 +945,15 @@ fn watchdog<T: event::CommandSink + TimerQuery + Send>(shared_state: Arc<SharedS
};

if result.timed_out() {
if !has_timed_out {
log::error!(target: "Auto Splitter", "timeout, no update in {} seconds", TIMEOUT.as_secs_f32());
has_timed_out = true;
}
if let Some(auto_splitter) = &*shared_state.auto_splitter.load() {
auto_splitter.interrupt_handle().interrupt();
}
} else {
has_timed_out = false;
}

new_state
Expand Down

0 comments on commit d35ff05

Please sign in to comment.