From ac9180ac465443370b6893841c1ce84497d936e3 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Fri, 3 Aug 2018 19:32:46 -0700 Subject: [PATCH] simplify channel impl --- src/server/accept.rs | 1 - src/server/channel.rs | 34 ++++++++++------------------------ src/server/srv.rs | 2 -- src/server/worker.rs | 5 ++--- 4 files changed, 12 insertions(+), 30 deletions(-) diff --git a/src/server/accept.rs b/src/server/accept.rs index e837852d..61bc72fb 100644 --- a/src/server/accept.rs +++ b/src/server/accept.rs @@ -470,7 +470,6 @@ impl Accept { io, token: info.token, peer: Some(addr), - http2: false, }, Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => return, Err(ref e) if connection_error(e) => continue, diff --git a/src/server/channel.rs b/src/server/channel.rs index b817b416..c158f66b 100644 --- a/src/server/channel.rs +++ b/src/server/channel.rs @@ -2,7 +2,7 @@ use std::net::{Shutdown, SocketAddr}; use std::rc::Rc; use std::{io, ptr, time}; -use bytes::{Buf, BufMut, Bytes, BytesMut}; +use bytes::{Buf, BufMut, BytesMut}; use futures::{Async, Future, Poll}; use tokio_io::{AsyncRead, AsyncWrite}; @@ -38,32 +38,18 @@ where H: HttpHandler + 'static, { pub(crate) fn new( - settings: Rc>, mut io: T, peer: Option, - http2: bool, + settings: Rc>, io: T, peer: Option, ) -> HttpChannel { settings.add_channel(); - let _ = io.set_nodelay(true); - if http2 { - HttpChannel { - node: None, - proto: Some(HttpProtocol::H2(h2::Http2::new( - settings, - io, - peer, - Bytes::new(), - ))), - } - } else { - HttpChannel { - node: None, - proto: Some(HttpProtocol::Unknown( - settings, - peer, - io, - BytesMut::with_capacity(8192), - )), - } + HttpChannel { + node: None, + proto: Some(HttpProtocol::Unknown( + settings, + peer, + io, + BytesMut::with_capacity(8192), + )), } } diff --git a/src/server/srv.rs b/src/server/srv.rs index 33c820aa..7e50e12b 100644 --- a/src/server/srv.rs +++ b/src/server/srv.rs @@ -510,7 +510,6 @@ impl HttpServer { io: WrapperStream::new(t), token: Token::new(0), peer: None, - http2: false, })); self }); @@ -602,7 +601,6 @@ where Rc::clone(self.settings.as_ref().unwrap()), msg.io, msg.peer, - msg.http2, )); } } diff --git a/src/server/worker.rs b/src/server/worker.rs index 3b8f426d..168382e6 100644 --- a/src/server/worker.rs +++ b/src/server/worker.rs @@ -25,7 +25,6 @@ pub(crate) struct Conn { pub io: T, pub token: Token, pub peer: Option, - pub http2: bool, } #[derive(Clone, Copy)] @@ -428,7 +427,7 @@ where }; let _ = io.set_nodelay(true); - current_thread::spawn(HttpChannel::new(h, io, peer, false)); + current_thread::spawn(HttpChannel::new(h, io, peer)); } } @@ -491,7 +490,7 @@ where current_thread::spawn(self.acceptor.accept(io).then(move |res| { h.conn_rate_del(); match res { - Ok(io) => current_thread::spawn(HttpChannel::new(h, io, peer, false)), + Ok(io) => current_thread::spawn(HttpChannel::new(h, io, peer)), Err(err) => trace!("Can not establish connection: {}", err), } Ok(())