chiark / gitweb /
move rx check
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 3 Aug 2021 23:02:16 +0000 (00:02 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 3 Aug 2021 23:02:24 +0000 (00:02 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/client.rs

index fde8058cf79963e86d447f529f1e461ad65823f9..56a6c6d1d5ef199c3275db2d426ebd6fc4178528 100644 (file)
@@ -199,15 +199,6 @@ async fn run_client<C:HCC>(
 
   async {
     loop {
-      let rx_fullness =
-        if rx_queue.remaining() < ic.max_batch_down.sat() * 3 /* xxx */ {
-          // xxx make this separate option ? docs say server only
-          Ok(())
-        } else {
-          Err(anyhow!("rx queue full"))
-        };
-      let rx_fullness_ok = reporter.lock().report(None, rx_fullness);
-
       select! {
         data = tx_stream.next_segment(),
         if packets.is_empty() =>
@@ -242,10 +233,17 @@ async fn run_client<C:HCC>(
         },
 
         _ = async { },
-        if rx_fullness_ok.is_some() &&
-           (reqs.len() < ic.target_requests_outstanding.sat() ||
-            (reqs.len() < ic.max_requests_outstanding.sat() &&
-             ! upbound.is_empty()))
+        if reporter.lock().report(None, {
+          if rx_queue.remaining() < ic.max_batch_down.sat() * 3 /* xxx */ {
+            // xxx make this separate option ? docs say server only
+            Ok(())
+          } else {
+            Err(anyhow!("rx queue full"))
+          }
+        }).is_some() &&
+          (reqs.len() < ic.target_requests_outstanding.sat() ||
+           (reqs.len() < ic.max_requests_outstanding.sat() &&
+            ! upbound.is_empty()))
           // xxx backpressure, if too much in rx_queue
           =>
         {