chiark / gitweb /
server: reorganise setup
[hippotat.git] / src / bin / server.rs
index fe161cc27f198f4710b7eb5abb222bfe4dc2122a..297740a1552ff729de9b71c3f6a5c902f54502d6 100644 (file)
@@ -18,11 +18,11 @@ const METADATA_MAX_LEN: usize = MAX_OVERHEAD;
 #[derive(Debug)]
 struct Global {
   config: config::InstanceConfigGlobal,
-  all_clients: HashMap<ClientName, ClientHandles>,
+  all_clients: HashMap<ClientName, Client>,
 }
 
 #[derive(Debug)]
-struct ClientHandles {
+struct Client {
   ic: Arc<InstanceConfig>,
   web: tokio::sync::mpsc::Sender<WebRequest>,
 }
@@ -425,6 +425,7 @@ async fn main() {
 
     let ipif = Ipif::start(&global_config.ipif, None)?;
 
+    let ics = ics.into_iter().map(Arc::new).collect_vec();
     let (client_handles_send, client_handles_recv) = ics.iter()
       .map(|_ic| mpsc::channel(
         5 // xxx should me max_requests_outstanding but that's
@@ -436,18 +437,18 @@ async fn main() {
       client_handles_send,
       client_handles_recv,
     ).map(|(ic, web_send, web_recv)| {
-      let ic = Arc::new(ic);
+      let r = (ic.link.client,
+           Client {
+             ic: ic.clone(),
+             web: web_send,
+           });
 
       let ic_ = ic.clone();
       tasks.push((tokio::spawn(async move {
         run_client(ic_, web_recv).await.void_unwrap_err()
       }), format!("client {}", &ic)));
 
-      (ic.link.client,
-       ClientHandles {
-         ic,
-         web: web_send,
-       })
+      r
     }).collect();
     let global = Arc::new(Global {
       config: global_config,