-
Notifications
You must be signed in to change notification settings - Fork 58
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.