From: Ian Jackson Date: Sat, 7 Aug 2021 23:54:44 +0000 (+0100) Subject: ipif: wip break out X-Git-Tag: hippotat/1.0.0~248 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=d39466da4b5b7a0c2190ee15f37790523dafe956;p=hippotat.git ipif: wip break out Signed-off-by: Ian Jackson --- diff --git a/src/bin/client.rs b/src/bin/client.rs index 241504d..9c139d2 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -292,25 +292,7 @@ async fn run_client( } }.await; - drop(ipif.tx_stream); - - match ipif.child.wait().await { - Err(e) => error!("{}: also, failed to await ipif child: {}", &ic, e), - Ok(st) => { - let stderr_timeout = Duration::from_millis(1000); - match tokio::time::timeout(stderr_timeout, ipif.stderr_task).await { - Err::<_,tokio::time::error::Elapsed>(_) - => warn!("{}: ipif stderr task continues!", &ic), - Ok(Err(e)) => error!("{}: ipif stderr task crashed: {}", &ic, e), - Ok(Ok(Err(e))) => error!("{}: ipif stderr read failed: {}", &ic, e), - Ok(Ok(Ok(()))) => { }, - } - if ! st.success() { - error!("{}: ipif process failed: {}", &ic, st); - } - } - } - + ipif.quitting(&ic).await; trouble } diff --git a/src/ipif.rs b/src/ipif.rs index 5455ef2..f2d7f20 100644 --- a/src/ipif.rs +++ b/src/ipif.rs @@ -43,4 +43,25 @@ impl Ipif { child, } } + + pub async fn quitting(mut self, ic: &InstanceConfig) { + drop(self.tx_stream); + + match self.child.wait().await { + Err(e) => error!("{}: also, failed to await ipif child: {}", &ic, e), + Ok(st) => { + let stderr_timeout = Duration::from_millis(1000); + match tokio::time::timeout(stderr_timeout, self.stderr_task).await { + Err::<_,tokio::time::error::Elapsed>(_) + => warn!("{}: ipif stderr task continues!", &ic), + Ok(Err(e)) => error!("{}: ipif stderr task crashed: {}", &ic, e), + Ok(Ok(Err(e))) => error!("{}: ipif stderr read failed: {}", &ic, e), + Ok(Ok(Ok(()))) => { }, + } + if ! st.success() { + error!("{}: ipif process failed: {}", &ic, st); + } + } + } + } }