From 6e9d9ba4189d5b65327c6baba8f409d4a0fdf3e9 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 16 Aug 2021 00:08:02 +0100 Subject: [PATCH] server: Break out OutstandingInner Signed-off-by: Ian Jackson --- src/bin/server.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/bin/server.rs b/src/bin/server.rs index 65b7e48..cf0eec1 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -224,6 +224,10 @@ async fn run_client(ic: Arc, { struct Outstanding { reply_to: tokio::sync::oneshot::Sender, + oi: OutstandingInner, + } + #[derive(Debug)] + struct OutstandingInner { target_requests_outstanding: u32, } let mut outstanding: VecDeque = default(); @@ -242,7 +246,7 @@ async fn run_client(ic: Arc, if ! downbound.is_empty() { outstanding.pop_front() } else if let Some((i,_)) = outstanding.iter().enumerate().find({ - |(_,o)| outstanding.len() > o.target_requests_outstanding.sat() + |(_,o)| outstanding.len() > o.oi.target_requests_outstanding.sat() }) { Some(outstanding.remove(i).unwrap()) } else { @@ -332,14 +336,12 @@ async fn run_client(ic: Arc, dbg!(comp.name, DumpHex(comp.payload)); } - Ok::<_,AE>(target_requests_outstanding) + let oi = OutstandingInner { + target_requests_outstanding, + }; + Ok::<_,AE>(oi) }.await { - Ok(target_requests_outstanding) => { - outstanding.push_back(Outstanding { - reply_to, - target_requests_outstanding, - }); - }, + Ok(oi) => outstanding.push_back(Outstanding { reply_to, oi }), Err(e) => { try_send_response(reply_to, WebResponse { data: Err(e), -- 2.30.2