From aac0c498c3549eba04eb682cdf0d21a191c85528 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 7 Aug 2021 13:50:36 +0100 Subject: [PATCH] client: better logging of ipif failures Signed-off-by: Ian Jackson --- src/bin/client.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/bin/client.rs b/src/bin/client.rs index 75e868d..8d29bea 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -189,7 +189,7 @@ async fn run_client( let stderr = ipif.stderr.take().unwrap(); let ic_name = ic.to_string(); - let _ = task::spawn(async move { + let stderr_task = task::spawn(async move { let mut stderr = tokio::io::BufReader::new(stderr).lines(); while let Some(l) = stderr.next_line().await? { error!("{}: ipif stderr: {}", &ic_name, l.trim_end()); @@ -316,8 +316,19 @@ async fn run_client( match ipif.wait().await { Err(e) => error!("{}: also, failed to await ipif child: {}", &ic, e), - Ok(st) if st.success() => { }, - Ok(st) => error!("{}: ipif process failed: {}", &ic, st), + Ok(st) => { + let stderr_timeout = Duration::from_millis(100); + match tokio::time::timeout(stderr_timeout, 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); + } + } } trouble -- 2.30.2