From c6143f9246943f7d6294ba8366d6726e6ce365ef Mon Sep 17 00:00:00 2001 From: Matthieu Le brazidec Date: Fri, 8 Nov 2019 00:18:22 +0100 Subject: [PATCH] Updated children group's run to poll children before getting new messages and to be pending when its broadcast stream is, and fixed supervisors to update the id of supervised elements in the order list after resetting them and when using the one-for-one supervision strategy. Signed-off-by: Matthieu Le brazidec --- bastion/src/children.rs | 10 +++++----- bastion/src/supervisor.rs | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bastion/src/children.rs b/bastion/src/children.rs index 14836eba..23faa917 100644 --- a/bastion/src/children.rs +++ b/bastion/src/children.rs @@ -350,6 +350,10 @@ impl Children { async fn run(mut self) -> Self { loop { + for (_, launched) in self.launched.values_mut() { + let _ = poll!(launched); + } + match poll!(&mut self.bcast.next()) { // TODO: Err if started == true? Poll::Ready(Some(BastionMessage::Start)) => { @@ -382,11 +386,7 @@ impl Children { return self; } - Poll::Pending => (), - } - - for (_, launched) in self.launched.values_mut() { - let _ = poll!(launched); + Poll::Pending => pending!(), } } } diff --git a/bastion/src/supervisor.rs b/bastion/src/supervisor.rs index 86e41d7f..9be70f71 100644 --- a/bastion/src/supervisor.rs +++ b/bastion/src/supervisor.rs @@ -562,7 +562,8 @@ impl Supervisor { } let launched = supervised.launch(); - self.launched.insert(id, (order, launched)); + self.launched.insert(id.clone(), (order, launched)); + self.order[order] = id; } SupervisionStrategy::OneForAll => { // TODO: stop or kill?