Skip to content

Commit 380e11b

Browse files
mariusaefacebook-github-bot
authored andcommitted
fix bug in maybe_unlink_parent (#420)
Summary: Pull Request resolved: #420 It was meant to return the parent only when it was actually unlinked. Happily, the net effect of this bug was that we printed spurious "instances was dropped while parent was linked". ghstack-source-id: 294110249 Reviewed By: shayne-fletcher Differential Revision: D77705185 fbshipit-source-id: 2c03efada909ee4780725c78d98caea92bfb34b9
1 parent aa05f63 commit 380e11b

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

hyperactor/src/proc.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,17 +1338,15 @@ impl InstanceState {
13381338
/// Unlink this instance from its parent, if it has one. If it was unlinked,
13391339
/// the parent is returned.
13401340
fn maybe_unlink_parent(&self) -> Option<InstanceCell> {
1341-
let result = self.parent.upgrade();
1342-
if let Some(parent) = &result {
1343-
parent.inner.unlink(self);
1344-
}
1345-
result
1341+
self.parent
1342+
.upgrade()
1343+
.filter(|parent| parent.inner.unlink(self))
13461344
}
13471345

13481346
/// Unlink this instance from a child.
1349-
fn unlink(&self, child: &InstanceState) {
1347+
fn unlink(&self, child: &InstanceState) -> bool {
13501348
assert_eq!(self.actor_id.proc_id(), child.actor_id.proc_id());
1351-
self.children.remove(&child.actor_id.pid());
1349+
self.children.remove(&child.actor_id.pid()).is_some()
13521350
}
13531351
}
13541352

0 commit comments

Comments
 (0)