mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-28 01:52:57 +01:00
simplify channel impl
This commit is contained in:
parent
e34b5c08ba
commit
ac9180ac46
@ -470,7 +470,6 @@ impl Accept {
|
|||||||
io,
|
io,
|
||||||
token: info.token,
|
token: info.token,
|
||||||
peer: Some(addr),
|
peer: Some(addr),
|
||||||
http2: false,
|
|
||||||
},
|
},
|
||||||
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => return,
|
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => return,
|
||||||
Err(ref e) if connection_error(e) => continue,
|
Err(ref e) if connection_error(e) => continue,
|
||||||
|
@ -2,7 +2,7 @@ use std::net::{Shutdown, SocketAddr};
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::{io, ptr, time};
|
use std::{io, ptr, time};
|
||||||
|
|
||||||
use bytes::{Buf, BufMut, Bytes, BytesMut};
|
use bytes::{Buf, BufMut, BytesMut};
|
||||||
use futures::{Async, Future, Poll};
|
use futures::{Async, Future, Poll};
|
||||||
use tokio_io::{AsyncRead, AsyncWrite};
|
use tokio_io::{AsyncRead, AsyncWrite};
|
||||||
|
|
||||||
@ -38,32 +38,18 @@ where
|
|||||||
H: HttpHandler + 'static,
|
H: HttpHandler + 'static,
|
||||||
{
|
{
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
settings: Rc<WorkerSettings<H>>, mut io: T, peer: Option<SocketAddr>,
|
settings: Rc<WorkerSettings<H>>, io: T, peer: Option<SocketAddr>,
|
||||||
http2: bool,
|
|
||||||
) -> HttpChannel<T, H> {
|
) -> HttpChannel<T, H> {
|
||||||
settings.add_channel();
|
settings.add_channel();
|
||||||
let _ = io.set_nodelay(true);
|
|
||||||
|
|
||||||
if http2 {
|
HttpChannel {
|
||||||
HttpChannel {
|
node: None,
|
||||||
node: None,
|
proto: Some(HttpProtocol::Unknown(
|
||||||
proto: Some(HttpProtocol::H2(h2::Http2::new(
|
settings,
|
||||||
settings,
|
peer,
|
||||||
io,
|
io,
|
||||||
peer,
|
BytesMut::with_capacity(8192),
|
||||||
Bytes::new(),
|
)),
|
||||||
))),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
HttpChannel {
|
|
||||||
node: None,
|
|
||||||
proto: Some(HttpProtocol::Unknown(
|
|
||||||
settings,
|
|
||||||
peer,
|
|
||||||
io,
|
|
||||||
BytesMut::with_capacity(8192),
|
|
||||||
)),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,7 +510,6 @@ impl<H: IntoHttpHandler> HttpServer<H> {
|
|||||||
io: WrapperStream::new(t),
|
io: WrapperStream::new(t),
|
||||||
token: Token::new(0),
|
token: Token::new(0),
|
||||||
peer: None,
|
peer: None,
|
||||||
http2: false,
|
|
||||||
}));
|
}));
|
||||||
self
|
self
|
||||||
});
|
});
|
||||||
@ -602,7 +601,6 @@ where
|
|||||||
Rc::clone(self.settings.as_ref().unwrap()),
|
Rc::clone(self.settings.as_ref().unwrap()),
|
||||||
msg.io,
|
msg.io,
|
||||||
msg.peer,
|
msg.peer,
|
||||||
msg.http2,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ pub(crate) struct Conn<T> {
|
|||||||
pub io: T,
|
pub io: T,
|
||||||
pub token: Token,
|
pub token: Token,
|
||||||
pub peer: Option<net::SocketAddr>,
|
pub peer: Option<net::SocketAddr>,
|
||||||
pub http2: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
@ -428,7 +427,7 @@ where
|
|||||||
};
|
};
|
||||||
let _ = io.set_nodelay(true);
|
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| {
|
current_thread::spawn(self.acceptor.accept(io).then(move |res| {
|
||||||
h.conn_rate_del();
|
h.conn_rate_del();
|
||||||
match res {
|
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),
|
Err(err) => trace!("Can not establish connection: {}", err),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user