From c92ecabb72421fcfc77fd0d85c81b84832c88b42 Mon Sep 17 00:00:00 2001 From: Finn Bear Date: Sat, 24 Aug 2024 00:59:35 -0700 Subject: [PATCH] Cleanup. --- src/proto/h1/conn.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/proto/h1/conn.rs b/src/proto/h1/conn.rs index 03018c6aad..81f1cd5475 100644 --- a/src/proto/h1/conn.rs +++ b/src/proto/h1/conn.rs @@ -2,8 +2,8 @@ use std::fmt; #[cfg(feature = "server")] use std::future::Future; use std::io; -use std::mem; use std::marker::{PhantomData, Unpin}; +use std::mem; use std::pin::Pin; use std::task::{Context, Poll}; #[cfg(feature = "server")] @@ -233,6 +233,7 @@ where if !self.state.h1_header_read_timeout_running { if let Some(h1_header_read_timeout) = self.state.h1_header_read_timeout { let deadline = Instant::now() + h1_header_read_timeout; + self.state.h1_idle_timeout_running = false; self.state.h1_header_read_timeout_running = true; match self.state.h1_timeout_fut { Some(ref mut ht_timeout_fut) => { @@ -249,7 +250,8 @@ where self.state.h1_timeout_fut = None; } } - } else if !self.state.h1_header_read_timeout_running && !self.state.h1_idle_timeout_running { + } else if !self.state.h1_header_read_timeout_running && !self.state.h1_idle_timeout_running + { if let Some(h1_idle_timeout) = self.state.h1_idle_timeout { let deadline = Instant::now() + h1_idle_timeout; self.state.h1_idle_timeout_running = true; @@ -260,8 +262,7 @@ where } None => { trace!("setting h1 timeout timer for idle"); - self.state.h1_timeout_fut = - Some(self.state.timer.sleep_until(deadline)); + self.state.h1_timeout_fut = Some(self.state.timer.sleep_until(deadline)); } } } @@ -287,17 +288,17 @@ where Poll::Pending => { #[cfg(feature = "server")] if self.state.h1_header_read_timeout_running || self.state.h1_idle_timeout_running { - if let Some(ref mut h1_timeout_fut) = - self.state.h1_timeout_fut - { + if let Some(ref mut h1_timeout_fut) = self.state.h1_timeout_fut { if Pin::new(h1_timeout_fut).poll(cx).is_ready() { - return Poll::Ready(Some(Err(if self.state.h1_header_read_timeout_running { - warn!("read header from client timeout"); - crate::Error::new_header_timeout() - } else { - warn!("idle client timeout"); - crate::Error::new_idle_timeout() - }))); + return Poll::Ready(Some(Err( + if self.state.h1_header_read_timeout_running { + warn!("read header from client timeout"); + crate::Error::new_header_timeout() + } else { + warn!("idle client timeout"); + crate::Error::new_idle_timeout() + }, + ))); } } }