mirror of https://github.com/fafhrd91/actix-web
rename ka_timer => timer
This commit is contained in:
parent
09cb93b7f0
commit
79b16d8efa
|
@ -155,8 +155,10 @@ pin_project! {
|
||||||
// Updated when messages are read from stream and after timer is used for
|
// Updated when messages are read from stream and after timer is used for
|
||||||
// first-request timeout.
|
// first-request timeout.
|
||||||
ka_deadline: Instant,
|
ka_deadline: Instant,
|
||||||
|
|
||||||
|
// Timer used for first-request, keep-alive, and shutdown timeouts.
|
||||||
#[pin]
|
#[pin]
|
||||||
ka_timer: Option<Sleep>,
|
timer: Option<Sleep>,
|
||||||
|
|
||||||
io: Option<T>,
|
io: Option<T>,
|
||||||
read_buf: BytesMut,
|
read_buf: BytesMut,
|
||||||
|
@ -257,7 +259,7 @@ where
|
||||||
messages: VecDeque::new(),
|
messages: VecDeque::new(),
|
||||||
|
|
||||||
ka_deadline,
|
ka_deadline,
|
||||||
ka_timer,
|
timer: ka_timer,
|
||||||
|
|
||||||
io: Some(io),
|
io: Some(io),
|
||||||
read_buf: BytesMut::with_capacity(HW_BUFFER_SIZE),
|
read_buf: BytesMut::with_capacity(HW_BUFFER_SIZE),
|
||||||
|
@ -770,7 +772,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if updated && this.ka_timer.is_some() {
|
if updated && this.timer.is_some() {
|
||||||
if let Some(expire) = this.codec.config().keep_alive_deadline() {
|
if let Some(expire) = this.codec.config().keep_alive_deadline() {
|
||||||
*this.ka_deadline = expire;
|
*this.ka_deadline = expire;
|
||||||
}
|
}
|
||||||
|
@ -779,24 +781,19 @@ where
|
||||||
Ok(updated)
|
Ok(updated)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// keep-alive timer
|
/// Poll first-request/keep-alive/disconnect timer.
|
||||||
fn poll_keepalive(
|
fn poll_timer(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Result<(), DispatchError> {
|
||||||
mut self: Pin<&mut Self>,
|
|
||||||
cx: &mut Context<'_>,
|
|
||||||
) -> Result<(), DispatchError> {
|
|
||||||
let mut this = self.as_mut().project();
|
let mut this = self.as_mut().project();
|
||||||
|
|
||||||
// when a branch is not explicit return early it's meant to fall through
|
match this.timer.as_mut().as_pin_mut() {
|
||||||
// and return as Ok(())
|
|
||||||
match this.ka_timer.as_mut().as_pin_mut() {
|
|
||||||
None => {
|
None => {
|
||||||
// conditionally go into shutdown timeout
|
// conditionally go into shutdown timeout
|
||||||
if this.flags.contains(Flags::SHUTDOWN) {
|
if this.flags.contains(Flags::SHUTDOWN) {
|
||||||
if let Some(deadline) = this.codec.config().client_disconnect_deadline() {
|
if let Some(deadline) = this.codec.config().client_disconnect_deadline() {
|
||||||
// write client disconnect time out and poll again to
|
// write client disconnect time out and poll again to
|
||||||
// go into Some(timer) branch
|
// go into Some(timer) branch
|
||||||
this.ka_timer.set(Some(sleep_until(deadline)));
|
this.timer.set(Some(sleep_until(deadline)));
|
||||||
return self.poll_keepalive(cx);
|
return self.poll_timer(cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -990,7 +987,7 @@ where
|
||||||
|
|
||||||
match this.inner.project() {
|
match this.inner.project() {
|
||||||
DispatcherStateProj::Normal { mut inner } => {
|
DispatcherStateProj::Normal { mut inner } => {
|
||||||
inner.as_mut().poll_keepalive(cx)?;
|
inner.as_mut().poll_timer(cx)?;
|
||||||
|
|
||||||
if inner.flags.contains(Flags::SHUTDOWN) {
|
if inner.flags.contains(Flags::SHUTDOWN) {
|
||||||
if inner.flags.contains(Flags::WRITE_DISCONNECT) {
|
if inner.flags.contains(Flags::WRITE_DISCONNECT) {
|
||||||
|
|
Loading…
Reference in New Issue