chiark / gitweb /
fixes etc.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 Aug 2021 16:28:37 +0000 (17:28 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 Aug 2021 16:28:37 +0000 (17:28 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
server/slocal.rs
server/suser.rs
server/sweb.rs

index 19944119e00deb2a2b070b3c94bb950b2e10fd27..f58ef9cdcff0bd17c9248d82eb14a3761d9e9420 100644 (file)
@@ -4,8 +4,6 @@
 
 use super::*;
 
-#[allow(dead_code)] // xxx
-#[allow(unused_variables)] // xxx
 pub async fn run(global: Arc<Global>,
                  mut rx: mpsc::Receiver<RoutedPacket>,
                  mut ipif: Ipif) -> Result<Void,AE> {
@@ -60,7 +58,7 @@ pub async fn run(global: Arc<Global>,
                 daddr, saddr, data.len());
             },
 
-            Ok((data, (saddr, daddr))) => {
+            Ok((data, (_saddr, daddr))) => {
               goodness += 1;
               route_packet(
                 &global, "ipif", None,
index 98ee84cb23f1b293fb087d977ab74ae7751f02b5..c2f11ff09cbc73a5d4d7eb9b421972d375f3a9a4 100644 (file)
@@ -11,8 +11,6 @@ pub struct User {
   pub route: mpsc::Sender<RoutedPacket>,
 }
 
-#[allow(unused_variables)] // xxx
-#[allow(unused_mut)] // xxx
 pub async fn run(global: Arc<Global>,
                  ic: Arc<InstanceConfig>,
                  mut web: mpsc::Receiver<WebRequest>,
@@ -25,7 +23,9 @@ pub async fn run(global: Arc<Global>,
   }
   #[derive(Debug)]
   struct OutstandingInner {
+    deadline: Instant,
     target_requests_outstanding: u32,
+    max_batch_down: u32,
   }
   let mut outstanding: VecDeque<Outstanding> = default();
   let mut downbound: PacketQueue<RoutedPacketData> = default();
@@ -39,11 +39,19 @@ pub async fn run(global: Arc<Global>,
   };
 
   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<Global>,
         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<Global>,
 
     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<Global>,
             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<Global>,
             ).await?;
           }
 
+          let deadline = Instant::now() + http_timeout;
+
           let oi = OutstandingInner {
             target_requests_outstanding,
+            max_batch_down,
+            deadline,
           };
           Ok::<_,AE>(oi)
         }.await {
index 0176e46afba58b28d0add5581b7b073d1e0b7fb5..49416c6226bc1319cd83da8ad52c6da9d75abae9 100644 (file)
@@ -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,