From 46e8b5926e2a0812023f31ff47286a804962dfcd Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 17 Aug 2021 00:35:55 +0100 Subject: [PATCH] server: reorganise setup Signed-off-by: Ian Jackson --- src/bin/server.rs | 18 ++++++++++++------ src/prelude.rs | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/bin/server.rs b/src/bin/server.rs index 8effeff..fe161cc 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -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 { diff --git a/src/prelude.rs b/src/prelude.rs index 1074678..c0392ab 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -33,7 +33,7 @@ pub use hyper::body::{Bytes, Buf as _}; pub use hyper::{Method, Uri}; pub use hyper_tls::HttpsConnector; pub use ipnet::IpNet; -pub use itertools::{iproduct, Itertools}; +pub use itertools::{iproduct, izip, Itertools}; pub use lazy_regex::{regex_captures, regex_is_match, regex_replace_all}; pub use lazy_static::lazy_static; pub use log::{trace, debug, info, warn, error}; -- 2.30.2