1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-30 18:44:35 +01:00

Re-use tcp listener on pause/resume

This commit is contained in:
Nikolay Kim 2018-05-20 20:47:20 -07:00
parent 483db7028c
commit 285c73e95e
3 changed files with 7 additions and 15 deletions

View File

@ -2,6 +2,8 @@
* Fix scope resource path extractor #234 * Fix scope resource path extractor #234
* Re-use tcp listener on pause/resume
## 0.6.7 (2018-05-17) ## 0.6.7 (2018-05-17)

View File

@ -450,7 +450,6 @@ impl<H: IntoHttpHandler> HttpServer<H> {
self.accept.push(start_accept_thread( self.accept.push(start_accept_thread(
token, token,
sock, sock,
self.backlog,
tx.clone(), tx.clone(),
socks.clone(), socks.clone(),
workers.clone(), workers.clone(),
@ -782,7 +781,7 @@ enum Command {
} }
fn start_accept_thread( fn start_accept_thread(
token: usize, sock: Socket, backlog: i32, srv: mpsc::UnboundedSender<ServerCommand>, token: usize, sock: Socket, srv: mpsc::UnboundedSender<ServerCommand>,
socks: Slab<SocketInfo>, socks: Slab<SocketInfo>,
mut workers: Vec<(usize, mpsc::UnboundedSender<Conn<net::TcpStream>>)>, mut workers: Vec<(usize, mpsc::UnboundedSender<Conn<net::TcpStream>>)>,
) -> (mio::SetReadiness, sync_mpsc::Sender<Command>) { ) -> (mio::SetReadiness, sync_mpsc::Sender<Command>) {
@ -892,8 +891,8 @@ fn start_accept_thread(
}, },
CMD => match rx.try_recv() { CMD => match rx.try_recv() {
Ok(cmd) => match cmd { Ok(cmd) => match cmd {
Command::Pause => if let Some(server) = server.take() { Command::Pause => if let Some(ref server) = server {
if let Err(err) = poll.deregister(&server) { if let Err(err) = poll.deregister(server) {
error!( error!(
"Can not deregister server socket {}", "Can not deregister server socket {}",
err err
@ -906,15 +905,6 @@ fn start_accept_thread(
} }
}, },
Command::Resume => { Command::Resume => {
let lst = create_tcp_listener(addr, backlog)
.expect("Can not create net::TcpListener");
server = Some(
mio::net::TcpListener::from_std(lst).expect(
"Can not create mio::net::TcpListener",
),
);
if let Some(ref server) = server { if let Some(ref server) = server {
if let Err(err) = poll.register( if let Err(err) = poll.register(
server, server,

View File

@ -239,9 +239,9 @@ impl StreamHandlerType {
match *self { match *self {
StreamHandlerType::Normal => "http", StreamHandlerType::Normal => "http",
#[cfg(feature = "tls")] #[cfg(feature = "tls")]
StreamHandlerType::Tls(ref acceptor) => "https", StreamHandlerType::Tls(_) => "https",
#[cfg(feature = "alpn")] #[cfg(feature = "alpn")]
StreamHandlerType::Alpn(ref acceptor) => "https", StreamHandlerType::Alpn(_) => "https",
} }
} }
} }