fix: Stack-overflow during shutdown

This commit is contained in:
Arne Beer 2024-06-23 12:38:28 +02:00
parent ec9e65664e
commit 7fc6fd244e
No known key found for this signature in database
GPG key ID: CC9408F679023B65

View file

@ -17,9 +17,13 @@ pub mod start;
/// We don't have to pause any groups, as no new tasks will be spawned during shutdown anyway.
/// Any groups with queued tasks, will be automatically paused on state-restoration.
pub fn initiate_shutdown(settings: &Settings, state: &mut LockedState, shutdown: Shutdown) {
state.shutdown = Some(shutdown);
self::kill::kill(settings, state, TaskSelection::All, false, None);
// Only start shutdown if we aren't already in one.
// Otherwise, we might end up with an endless recursion as `kill` might fail and initiate shutdown
// once again.
if state.shutdown.is_none() {
state.shutdown = Some(shutdown);
self::kill::kill(settings, state, TaskSelection::All, false, None);
}
}
/// This is a small wrapper around the real platform dependant process handling logic