diff --git a/Cargo.toml b/Cargo.toml index 51474c264..14102881a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "0.7.10" +version = "0.7.11" authors = ["Nikolay Kim "] description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust." readme = "README.md" diff --git a/README.md b/README.md index 4e396cb91..321f82abf 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ Actix web is a simple, pragmatic and extremely fast web framework for Rust. * Client/server [WebSockets](https://actix.rs/docs/websockets/) support * Transparent content compression/decompression (br, gzip, deflate) * Configurable [request routing](https://actix.rs/docs/url-dispatch/) -* Graceful server shutdown * Multipart streams * Static assets * SSL support with OpenSSL or `native-tls` @@ -51,7 +50,7 @@ fn main() { * [Protobuf support](https://github.com/actix/examples/tree/master/protobuf/) * [Multipart streams](https://github.com/actix/examples/tree/master/multipart/) * [Simple websocket](https://github.com/actix/examples/tree/master/websocket/) -* [Tera](https://github.com/actix/examples/tree/master/template_tera/) / +* [Tera](https://github.com/actix/examples/tree/master/template_tera/) / [Askama](https://github.com/actix/examples/tree/master/template_askama/) templates * [Diesel integration](https://github.com/actix/examples/tree/master/diesel/) * [r2d2](https://github.com/actix/examples/tree/master/r2d2/) @@ -66,8 +65,6 @@ You may consider checking out * [TechEmpower Framework Benchmark](https://www.techempower.com/benchmarks/#section=data-r16&hw=ph&test=plaintext) -* Some basic benchmarks could be found in this [repository](https://github.com/fafhrd91/benchmarks). - ## License This project is licensed under either of diff --git a/src/server/acceptor.rs b/src/server/acceptor.rs index a18dded9b..994b4b7bd 100644 --- a/src/server/acceptor.rs +++ b/src/server/acceptor.rs @@ -9,10 +9,7 @@ use tokio_reactor::Handle; use tokio_tcp::TcpStream; use tokio_timer::{sleep, Delay}; -// use super::channel::HttpProtocol; use super::error::AcceptorError; -use super::handler::HttpHandler; -use super::settings::ServiceConfig; use super::IoStream; /// This trait indicates types that can create acceptor service for http server. @@ -275,56 +272,49 @@ impl Future for AcceptorTimeoutResponse { } } -pub(crate) struct ServerMessageAcceptor { +pub(crate) struct ServerMessageAcceptor { inner: T, - settings: ServiceConfig, } -impl ServerMessageAcceptor +impl ServerMessageAcceptor where - H: HttpHandler, T: NewService, { - pub(crate) fn new(settings: ServiceConfig, inner: T) -> Self { - ServerMessageAcceptor { inner, settings } + pub(crate) fn new(inner: T) -> Self { + ServerMessageAcceptor { inner } } } -impl NewService for ServerMessageAcceptor +impl NewService for ServerMessageAcceptor where - H: HttpHandler, T: NewService, { type Request = ServerMessage; type Response = (); type Error = T::Error; type InitError = T::InitError; - type Service = ServerMessageAcceptorService; - type Future = ServerMessageAcceptorResponse; + type Service = ServerMessageAcceptorService; + type Future = ServerMessageAcceptorResponse; fn new_service(&self) -> Self::Future { ServerMessageAcceptorResponse { fut: self.inner.new_service(), - settings: self.settings.clone(), } } } -pub(crate) struct ServerMessageAcceptorResponse +pub(crate) struct ServerMessageAcceptorResponse where - H: HttpHandler, T: NewService, { fut: T::Future, - settings: ServiceConfig, } -impl Future for ServerMessageAcceptorResponse +impl Future for ServerMessageAcceptorResponse where - H: HttpHandler, T: NewService, { - type Item = ServerMessageAcceptorService; + type Item = ServerMessageAcceptorService; type Error = T::InitError; fn poll(&mut self) -> Poll { @@ -332,20 +322,17 @@ where Async::NotReady => Ok(Async::NotReady), Async::Ready(service) => Ok(Async::Ready(ServerMessageAcceptorService { inner: service, - settings: self.settings.clone(), })), } } } -pub(crate) struct ServerMessageAcceptorService { +pub(crate) struct ServerMessageAcceptorService { inner: T, - settings: ServiceConfig, } -impl Service for ServerMessageAcceptorService +impl Service for ServerMessageAcceptorService where - H: HttpHandler, T: Service, { type Request = ServerMessage; diff --git a/src/server/builder.rs b/src/server/builder.rs index ec6ce9923..4f159af13 100644 --- a/src/server/builder.rs +++ b/src/server/builder.rs @@ -60,7 +60,6 @@ where if secure { Either::B(ServerMessageAcceptor::new( - settings.clone(), TcpAcceptor::new(AcceptorTimeout::new( client_timeout, acceptor.create(), @@ -74,7 +73,6 @@ where )) } else { Either::A(ServerMessageAcceptor::new( - settings.clone(), TcpAcceptor::new(acceptor.create().map_err(AcceptorError::Service)) .map_err(|_| ()) .map_init_err(|_| ()) diff --git a/src/server/channel.rs b/src/server/channel.rs index af90d9346..d65b05e85 100644 --- a/src/server/channel.rs +++ b/src/server/channel.rs @@ -50,7 +50,6 @@ where H: HttpHandler + 'static, { proto: HttpProtocol, - node: Option>, ka_timeout: Option, } @@ -64,24 +63,11 @@ where HttpChannel { ka_timeout, - node: None, proto: HttpProtocol::Unknown(settings, io, BytesMut::with_capacity(8192)), } } } -impl Drop for HttpChannel -where - T: IoStream, - H: HttpHandler + 'static, -{ - fn drop(&mut self) { - if let Some(mut node) = self.node.take() { - node.remove() - } - } -} - impl Future for HttpChannel where T: IoStream, @@ -114,22 +100,6 @@ where } } - if self.node.is_none() { - self.node = Some(Node::new(())); - let _ = match self.proto { - HttpProtocol::H1(ref mut h1) => { - self.node.as_mut().map(|n| h1.settings().head().insert(n)) - } - HttpProtocol::H2(ref mut h2) => { - self.node.as_mut().map(|n| h2.settings().head().insert(n)) - } - HttpProtocol::Unknown(ref mut settings, _, _) => { - self.node.as_mut().map(|n| settings.head().insert(n)) - } - HttpProtocol::None => unreachable!(), - }; - } - let mut is_eof = false; let kind = match self.proto { HttpProtocol::H1(ref mut h1) => return h1.poll(), @@ -206,7 +176,6 @@ where H: HttpHandler + 'static, { proto: HttpProtocol, - node: Option>, } impl H1Channel @@ -216,7 +185,6 @@ where { pub(crate) fn new(settings: ServiceConfig, io: T) -> H1Channel { H1Channel { - node: None, proto: HttpProtocol::H1(h1::Http1Dispatcher::new( settings, io, @@ -228,18 +196,6 @@ where } } -impl Drop for H1Channel -where - T: IoStream, - H: HttpHandler + 'static, -{ - fn drop(&mut self) { - if let Some(mut node) = self.node.take() { - node.remove(); - } - } -} - impl Future for H1Channel where T: IoStream, @@ -249,16 +205,6 @@ where type Error = HttpDispatchError; fn poll(&mut self) -> Poll { - if self.node.is_none() { - self.node = Some(Node::new(())); - match self.proto { - HttpProtocol::H1(ref mut h1) => { - self.node.as_mut().map(|n| h1.settings().head().insert(n)); - } - _ => unreachable!(), - }; - } - match self.proto { HttpProtocol::H1(ref mut h1) => h1.poll(), _ => unreachable!(), @@ -266,88 +212,6 @@ where } } -pub(crate) struct Node { - next: Option<*mut Node>, - prev: Option<*mut Node>, - element: T, -} - -impl Node { - fn new(element: T) -> Self { - Node { - element, - next: None, - prev: None, - } - } - - fn insert(&mut self, next_el: &mut Node) { - let next: *mut Node = next_el as *const _ as *mut _; - - if let Some(next2) = self.next { - unsafe { - let n = next2.as_mut().unwrap(); - n.prev = Some(next); - } - next_el.next = Some(next2 as *mut _); - } - self.next = Some(next); - - unsafe { - let next: &mut Node = &mut *next; - next.prev = Some(self as *mut _); - } - } - - fn remove(&mut self) { - let next = self.next.take(); - let prev = self.prev.take(); - - if let Some(prev) = prev { - unsafe { - prev.as_mut().unwrap().next = next; - } - } - if let Some(next) = next { - unsafe { - next.as_mut().unwrap().prev = prev; - } - } - } -} - -impl Node<()> { - pub(crate) fn head() -> Self { - Node { - next: None, - prev: None, - element: (), - } - } - - pub(crate) fn traverse)>(&self, f: F) - where - T: IoStream, - H: HttpHandler + 'static, - { - if let Some(n) = self.next.as_ref() { - unsafe { - let mut next: &mut Node> = - &mut *(n.as_ref().unwrap() as *const _ as *mut _); - loop { - f(&mut next.element); - - next = if let Some(n) = next.next.as_ref() { - &mut **n - } else { - return; - } - } - } - } - } -} - /// Wrapper for `AsyncRead + AsyncWrite` types pub(crate) struct WrapperStream where diff --git a/src/server/h1.rs b/src/server/h1.rs index 0fb72ef7e..a2ffc0551 100644 --- a/src/server/h1.rs +++ b/src/server/h1.rs @@ -147,16 +147,6 @@ where disp } - #[inline] - pub fn settings(&self) -> &ServiceConfig { - &self.settings - } - - #[inline] - pub(crate) fn io(&mut self) -> &mut T { - self.stream.get_mut() - } - #[inline] fn can_read(&self) -> bool { if self.flags.contains(Flags::READ_DISCONNECTED) { diff --git a/src/server/h2.rs b/src/server/h2.rs index 6ad9af709..35afa3397 100644 --- a/src/server/h2.rs +++ b/src/server/h2.rs @@ -89,15 +89,6 @@ where } } - pub(crate) fn shutdown(&mut self) { - self.state = State::Empty; - self.tasks.clear(); - } - - pub fn settings(&self) -> &ServiceConfig { - &self.settings - } - pub fn poll(&mut self) -> Poll<(), HttpDispatchError> { self.poll_keepalive()?; diff --git a/src/server/settings.rs b/src/server/settings.rs index bafffb5f7..66a4eed88 100644 --- a/src/server/settings.rs +++ b/src/server/settings.rs @@ -1,4 +1,4 @@ -use std::cell::{Cell, RefCell, RefMut}; +use std::cell::{Cell, RefCell}; use std::collections::VecDeque; use std::fmt::Write; use std::rc::Rc; @@ -15,7 +15,6 @@ use time; use tokio_current_thread::spawn; use tokio_timer::{sleep, Delay}; -use super::channel::Node; use super::message::{Request, RequestPool}; use super::KeepAlive; use body::Body; @@ -138,7 +137,6 @@ struct Inner { ka_enabled: bool, bytes: Rc, messages: &'static RequestPool, - node: RefCell>, date: Cell>, } @@ -173,7 +171,6 @@ impl ServiceConfig { client_shutdown, bytes: Rc::new(SharedBytesPool::new()), messages: RequestPool::pool(settings), - node: RefCell::new(Node::head()), date: Cell::new(None), })) } @@ -183,10 +180,6 @@ impl ServiceConfig { ServiceConfigBuilder::new(handler) } - pub(crate) fn head(&self) -> RefMut> { - self.0.node.borrow_mut() - } - pub(crate) fn handler(&self) -> &H { &self.0.handler }