Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
finnbear committed Aug 24, 2024
1 parent 8d5a287 commit c92ecab
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/proto/h1/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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) => {
Expand All @@ -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;
Expand All @@ -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));
}
}
}
Expand All @@ -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()
},
)));
}
}
}
Expand Down

0 comments on commit c92ecab

Please sign in to comment.