From d39466da4b5b7a0c2190ee15f37790523dafe956 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 8 Aug 2021 00:54:44 +0100 Subject: [PATCH] ipif: wip break out Signed-off-by: Ian Jackson --- src/bin/client.rs | 20 +------------------- src/ipif.rs | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 19 deletions(-) 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); + } + } + } + } } -- 2.30.2