fix(maestro): classify exited ACP children
This commit is contained in:
@@ -379,8 +379,26 @@ impl SessionManager {
|
||||
if children.is_empty() {
|
||||
return;
|
||||
}
|
||||
tracing::info!(count = children.len(), "shutdown: ending adapter children");
|
||||
let terminations = children
|
||||
let reaped =
|
||||
futures_util::future::join_all(children.iter().map(|(_, acp, _)| acp.reap_if_exited()))
|
||||
.await;
|
||||
let mut natural_exits = Vec::new();
|
||||
let mut live_children = Vec::new();
|
||||
for (child, exited) in children.iter().cloned().zip(reaped) {
|
||||
if exited {
|
||||
natural_exits.push(child.0);
|
||||
} else {
|
||||
live_children.push(child);
|
||||
}
|
||||
}
|
||||
for id in natural_exits {
|
||||
mark_session_dead_with_worktree_settlement(&self.inner, id, true).await;
|
||||
}
|
||||
tracing::info!(
|
||||
count = live_children.len(),
|
||||
"shutdown: ending adapter children"
|
||||
);
|
||||
let terminations = live_children
|
||||
.iter()
|
||||
.map(|(_, acp, _)| acp.terminate(maestro_acp::CANCEL_GRACE, maestro_acp::TERM_GRACE));
|
||||
futures_util::future::join_all(terminations).await;
|
||||
@@ -389,7 +407,7 @@ impl SessionManager {
|
||||
.filter_map(|(_, _, done)| done.clone())
|
||||
.map(wait_for_event_pump);
|
||||
futures_util::future::join_all(drains).await;
|
||||
for (id, _, _) in children {
|
||||
for (id, _, _) in live_children {
|
||||
mark_session_dead_after_shutdown(&self.inner, id).await;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user