chiark / gitweb /
server: Break out OutstandingInner
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 15 Aug 2021 23:08:02 +0000 (00:08 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 15 Aug 2021 23:08:02 +0000 (00:08 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/server.rs

index 65b7e489e7182da08b514e3e6961f231b2ee4312..cf0eec1d34425d054a6ea298db5facd97b202836 100644 (file)
@@ -224,6 +224,10 @@ async fn run_client(ic: Arc<InstanceConfig>,
 {
   struct Outstanding {
     reply_to: tokio::sync::oneshot::Sender<WebResponse>,
+    oi: OutstandingInner,
+  }
+  #[derive(Debug)]
+  struct OutstandingInner {
     target_requests_outstanding: u32,
   }
   let mut outstanding: VecDeque<Outstanding> = default();
@@ -242,7 +246,7 @@ async fn run_client(ic: Arc<InstanceConfig>,
       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<InstanceConfig>,
             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),