chiark / gitweb /
server: reorganise setup
[hippotat.git] / src / bin / server.rs
index 8effeff9c2102b5a1bdf9b416bf349d2cce638b1..fe161cc27f198f4710b7eb5abb222bfe4dc2122a 100644 (file)
@@ -422,15 +422,21 @@ async fn main() {
     &opts.config, &opts.log, |ics|
   {
     let global_config = config::InstanceConfigGlobal::from(&ics);
-    let ipif = Ipif::start(&global_config.ipif, None)?;
 
-    let all_clients = ics.into_iter().map(|ic| {
-      let ic = Arc::new(ic);
+    let ipif = Ipif::start(&global_config.ipif, None)?;
 
-      let (web_send, web_recv) = mpsc::channel(
+    let (client_handles_send, client_handles_recv) = ics.iter()
+      .map(|_ic| mpsc::channel(
         5 // xxx should me max_requests_outstanding but that's
-          // marked client-only so needs rework
-      );
+        // marked client-only so needs rework
+      )).unzip::<_,_,Vec<_>,Vec<_>>();
+
+    let all_clients = izip!(
+      ics.into_iter(),
+      client_handles_send,
+      client_handles_recv,
+    ).map(|(ic, web_send, web_recv)| {
+      let ic = Arc::new(ic);
 
       let ic_ = ic.clone();
       tasks.push((tokio::spawn(async move {