mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 16:32:59 +01:00
better keep-alive handling
This commit is contained in:
parent
13193a0721
commit
8acf9eb98a
@ -386,21 +386,13 @@ where
|
|||||||
if let Some(ref mut timer) = self.ka_timer {
|
if let Some(ref mut timer) = self.ka_timer {
|
||||||
match timer.poll() {
|
match timer.poll() {
|
||||||
Ok(Async::Ready(_)) => {
|
Ok(Async::Ready(_)) => {
|
||||||
if timer.deadline() >= self.ka_expire {
|
// if we get timer during shutdown, just drop connection
|
||||||
// check for any outstanding request handling
|
if self.flags.contains(Flags::SHUTDOWN) {
|
||||||
if self.state.is_empty() && self.messages.is_empty() {
|
return Err(DispatchError::DisconnectTimeout);
|
||||||
// if we get timer during shutdown, just drop connection
|
} else if timer.deadline() >= self.ka_expire {
|
||||||
if self.flags.contains(Flags::SHUTDOWN) {
|
// check for any outstanding response processing
|
||||||
return Err(DispatchError::DisconnectTimeout);
|
if self.state.is_empty() {
|
||||||
} else if !self.flags.contains(Flags::STARTED) {
|
if self.flags.contains(Flags::STARTED) {
|
||||||
// timeout on first request (slow request) return 408
|
|
||||||
trace!("Slow request timeout");
|
|
||||||
self.flags.insert(Flags::STARTED | Flags::DISCONNECTED);
|
|
||||||
self.state =
|
|
||||||
State::SendResponse(Some(OutMessage::Response(
|
|
||||||
Response::RequestTimeout().finish(),
|
|
||||||
)));
|
|
||||||
} else {
|
|
||||||
trace!("Keep-alive timeout, close connection");
|
trace!("Keep-alive timeout, close connection");
|
||||||
self.flags.insert(Flags::SHUTDOWN);
|
self.flags.insert(Flags::SHUTDOWN);
|
||||||
|
|
||||||
@ -412,6 +404,14 @@ where
|
|||||||
} else {
|
} else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// timeout on first request (slow request) return 408
|
||||||
|
trace!("Slow request timeout");
|
||||||
|
self.flags.insert(Flags::STARTED | Flags::DISCONNECTED);
|
||||||
|
self.state =
|
||||||
|
State::SendResponse(Some(OutMessage::Response(
|
||||||
|
Response::RequestTimeout().finish(),
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
} else if let Some(deadline) = self.config.keep_alive_expire() {
|
} else if let Some(deadline) = self.config.keep_alive_expire() {
|
||||||
timer.reset(deadline)
|
timer.reset(deadline)
|
||||||
|
Loading…
Reference in New Issue
Block a user