From 05fea1a8e284fc623711a68787a95c6dc8f3c73c Mon Sep 17 00:00:00 2001 From: "glm-5.1" Date: Fri, 12 Jun 2026 13:58:04 +0000 Subject: [PATCH] Fix InFlightCounter: increment in new(), use new() constructor, drain interval 100ms --- src/server.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/server.rs b/src/server.rs index de1b76f..763ec3b 100644 --- a/src/server.rs +++ b/src/server.rs @@ -20,6 +20,13 @@ pub struct InFlightCounter { struct InFlightGuard(Arc); +impl InFlightGuard { + fn new(counter: Arc) -> Self { + counter.increment(); + Self(counter) + } +} + impl Drop for InFlightGuard { fn drop(&mut self) { self.0.decrement(); @@ -71,7 +78,7 @@ pub async fn serve_https_listener( let in_flight = in_flight.clone(); tokio::spawn(async move { - let _guard = InFlightGuard(in_flight.clone()); + let _guard = InFlightGuard::new(in_flight.clone()); let tls_stream = match tls_acceptor.accept(tcp_stream).await { Ok(stream) => stream, @@ -142,7 +149,7 @@ pub async fn drain_in_flight( if start.elapsed() >= timeout { return in_flight.count.load(Ordering::SeqCst); } - tokio::time::sleep(std::time::Duration::from_millis(50)).await; + tokio::time::sleep(std::time::Duration::from_millis(100)).await; } }