Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a timeout message #809

Merged
merged 2 commits into from
Nov 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This never gets reset to false again. The rest looks good.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, long term I think we want the watchdog to be more configurable (the timeout) and with a custom callback where the UI could then for example ask the user if they want to shut down the auto splitter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch, fixed in timeout: reset to false again.

}
if let Some(auto_splitter) = &*shared_state.auto_splitter.load() {
auto_splitter.interrupt_handle().interrupt();
}
} else {
has_timed_out = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is the right place. I think this should be set in the Unloaded case, so it doesn't get set all the time.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm, the reload case in the other thread never puts the watchdog into the unloaded state, so I guess this is fine.

}

new_state
Expand Down
Loading