From: Ian Jackson Date: Sun, 22 Aug 2021 16:28:37 +0000 (+0100) Subject: fixes etc. X-Git-Tag: hippotat/1.0.0~97 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=55567b861f856b69d509b4e2a8466cdefd848b66;p=hippotat.git fixes etc. Signed-off-by: Ian Jackson --- diff --git a/server/slocal.rs b/server/slocal.rs index 1994411..f58ef9c 100644 --- a/server/slocal.rs +++ b/server/slocal.rs @@ -4,8 +4,6 @@ use super::*; -#[allow(dead_code)] // xxx -#[allow(unused_variables)] // xxx pub async fn run(global: Arc, mut rx: mpsc::Receiver, mut ipif: Ipif) -> Result { @@ -60,7 +58,7 @@ pub async fn run(global: Arc, daddr, saddr, data.len()); }, - Ok((data, (saddr, daddr))) => { + Ok((data, (_saddr, daddr))) => { goodness += 1; route_packet( &global, "ipif", None, diff --git a/server/suser.rs b/server/suser.rs index 98ee84c..c2f11ff 100644 --- a/server/suser.rs +++ b/server/suser.rs @@ -11,8 +11,6 @@ pub struct User { pub route: mpsc::Sender, } -#[allow(unused_variables)] // xxx -#[allow(unused_mut)] // xxx pub async fn run(global: Arc, ic: Arc, mut web: mpsc::Receiver, @@ -25,7 +23,9 @@ pub async fn run(global: Arc, } #[derive(Debug)] struct OutstandingInner { + deadline: Instant, target_requests_outstanding: u32, + max_batch_down: u32, } let mut outstanding: VecDeque = default(); let mut downbound: PacketQueue = default(); @@ -39,11 +39,19 @@ pub async fn run(global: Arc, }; loop { + let eff_max_batch_down = outstanding + .iter() + .map(|o| o.oi.max_batch_down) + .min() + .unwrap_or(ic.max_batch_down) + .sat(); + if let Some(req) = { if ! downbound.is_empty() { outstanding.pop_front() } else if let Some((i,_)) = outstanding.iter().enumerate().find({ |(_,o)| outstanding.len() > o.oi.target_requests_outstanding.sat() + // xxx need timeout-based return too }) { Some(outstanding.remove(i).unwrap()) } else { @@ -56,7 +64,7 @@ pub async fn run(global: Arc, let next = if let Some(n) = downbound.peek_front() { n } else { break }; // Don't add 1 for the ESC since we will strip one - if build.len() + next.len() >= ic.max_batch_down.sat() { break } + if build.len() + next.len() >= eff_max_batch_down { break } build.esc_push(downbound.pop_front().unwrap()); } if ! build.is_empty() { @@ -74,7 +82,7 @@ pub async fn run(global: Arc, let max = usize::saturating_mul( ic.max_requests_outstanding.sat(), - ic.max_batch_down.sat(), + eff_max_batch_down, ).saturating_add(1 /* one boundary SLIP_ESC which we'll trim */); while downbound.total_len() > max { @@ -155,6 +163,7 @@ pub async fn run(global: Arc, max_batch_up, ( > ), client, let server, client = meta.parse()?.unwrap_or(server); } + let _ = max_batch_up; // we don't use this further while let Some(comp) = comps.next(&mut warnings, PartName::d)? { if comp.name != PartName::d { @@ -173,8 +182,12 @@ pub async fn run(global: Arc, ).await?; } + let deadline = Instant::now() + http_timeout; + let oi = OutstandingInner { target_requests_outstanding, + max_batch_down, + deadline, }; Ok::<_,AE>(oi) }.await { diff --git a/server/sweb.rs b/server/sweb.rs index 0176e46..49416c6 100644 --- a/server/sweb.rs +++ b/server/sweb.rs @@ -5,7 +5,6 @@ use super::*; /// Sent from hyper worker pool task to client task -#[allow(dead_code)] // xxx #[derive(Debug)] pub struct WebRequest { // initial part of body @@ -23,7 +22,6 @@ pub struct WebRequest { } /// Reply from client task to hyper worker pool task -#[allow(dead_code)] // xxx #[derive(Debug)] pub struct WebResponse { pub warnings: Warnings,