1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 00:21:08 +01:00

fix keep-alive timer reset

This commit is contained in:
Nikolay Kim 2018-11-07 21:09:33 -08:00
parent 8e354021d4
commit 2677d325a7
4 changed files with 35 additions and 13 deletions

View File

@ -1,16 +1,21 @@
# Changes
## [0.7.14] - 2018-10-x
## [0.7.14] - 2018-11-x
### Fixed
* Fix keep-alive timer reset
* HttpServer now treats streaming bodies the same for HTTP/1.x protocols. #549
### Added
* Add method to configure custom error handler to `Query` and `Path` extractors.
* Add method to configure `SameSite` option in `CookieIdentityPolicy`.
## [0.7.13] - 2018-10-14
### Fixed

View File

@ -1,6 +1,6 @@
[package]
name = "actix-web"
version = "0.7.13"
version = "0.7.14"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust."
readme = "README.md"

View File

@ -87,7 +87,10 @@ where
H: HttpHandler + 'static,
{
pub fn new(
settings: ServiceConfig<H>, stream: T, buf: BytesMut, is_eof: bool,
settings: ServiceConfig<H>,
stream: T,
buf: BytesMut,
is_eof: bool,
keepalive_timer: Option<Delay>,
) -> Self {
let addr = stream.peer_addr();
@ -123,8 +126,11 @@ where
}
pub(crate) fn for_error(
settings: ServiceConfig<H>, stream: T, status: StatusCode,
mut keepalive_timer: Option<Delay>, buf: BytesMut,
settings: ServiceConfig<H>,
stream: T,
status: StatusCode,
mut keepalive_timer: Option<Delay>,
buf: BytesMut,
) -> Self {
if let Some(deadline) = settings.client_timer_expire() {
let _ = keepalive_timer.as_mut().map(|delay| delay.reset(deadline));
@ -298,16 +304,19 @@ where
if let Some(deadline) =
self.settings.client_shutdown_timer()
{
timer.reset(deadline)
timer.reset(deadline);
let _ = timer.poll();
} else {
return Ok(());
}
}
} else if let Some(dl) = self.settings.keep_alive_expire() {
timer.reset(dl)
timer.reset(dl);
let _ = timer.poll();
}
} else {
timer.reset(self.ka_expire)
timer.reset(self.ka_expire);
let _ = timer.poll();
}
}
Ok(Async::NotReady) => (),

View File

@ -60,7 +60,10 @@ where
H: HttpHandler + 'static,
{
pub fn new(
settings: ServiceConfig<H>, io: T, buf: Bytes, keepalive_timer: Option<Delay>,
settings: ServiceConfig<H>,
io: T,
buf: Bytes,
keepalive_timer: Option<Delay>,
) -> Self {
let addr = io.peer_addr();
let extensions = io.extensions();
@ -284,10 +287,12 @@ where
if self.tasks.is_empty() {
return Err(HttpDispatchError::ShutdownTimeout);
} else if let Some(dl) = self.settings.keep_alive_expire() {
timer.reset(dl)
timer.reset(dl);
let _ = timer.poll();
}
} else {
timer.reset(self.ka_expire)
timer.reset(self.ka_expire);
let _ = timer.poll();
}
}
Ok(Async::NotReady) => (),
@ -348,8 +353,11 @@ struct Entry<H: HttpHandler + 'static> {
impl<H: HttpHandler + 'static> Entry<H> {
fn new(
parts: Parts, recv: RecvStream, resp: SendResponse<Bytes>,
addr: Option<SocketAddr>, settings: ServiceConfig<H>,
parts: Parts,
recv: RecvStream,
resp: SendResponse<Bytes>,
addr: Option<SocketAddr>,
settings: ServiceConfig<H>,
extensions: Option<Rc<Extensions>>,
) -> Entry<H>
where