chiark / gitweb /
ipif: wip break out
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Aug 2021 23:54:44 +0000 (00:54 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Aug 2021 23:54:44 +0000 (00:54 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/client.rs
src/ipif.rs

index 241504d1f0d2e3f1d9dd34e6a69406ab85106676..9c139d28ef8c6e48e9049b32a8a9b22355864b32 100644 (file)
@@ -292,25 +292,7 @@ async fn run_client<C:HCC>(
     }
   }.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
 }
 
index 5455ef271ea1a8d9269b772fc3778875e884a359..f2d7f205840fddcf1a8195e9f35ffa8111312c98 100644 (file)
@@ -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);
+        }
+      }
+    }
+  }
 }