1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-10-21 09:23:54 +00:00

simplify channel impl

This commit is contained in:
Nikolay Kim 2018-08-03 19:32:46 -07:00
parent e34b5c08ba
commit ac9180ac46
4 changed files with 12 additions and 30 deletions

View file

@ -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,

View file

@ -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<WorkerSettings<H>>, mut io: T, peer: Option<SocketAddr>,
http2: bool,
settings: Rc<WorkerSettings<H>>, io: T, peer: Option<SocketAddr>,
) -> HttpChannel<T, H> {
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),
)),
}
}

View file

@ -510,7 +510,6 @@ impl<H: IntoHttpHandler> HttpServer<H> {
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,
));
}
}

View file

@ -25,7 +25,6 @@ pub(crate) struct Conn<T> {
pub io: T,
pub token: Token,
pub peer: Option<net::SocketAddr>,
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(())