diff --git a/CHANGES.md b/CHANGES.md index 0e663644..7a751b64 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,8 @@ * Fix scope resource path extractor #234 +* Re-use tcp listener on pause/resume + ## 0.6.7 (2018-05-17) diff --git a/src/server/srv.rs b/src/server/srv.rs index 7ed533bf..18663103 100644 --- a/src/server/srv.rs +++ b/src/server/srv.rs @@ -450,7 +450,6 @@ impl HttpServer { self.accept.push(start_accept_thread( token, sock, - self.backlog, tx.clone(), socks.clone(), workers.clone(), @@ -782,7 +781,7 @@ enum Command { } fn start_accept_thread( - token: usize, sock: Socket, backlog: i32, srv: mpsc::UnboundedSender, + token: usize, sock: Socket, srv: mpsc::UnboundedSender, socks: Slab, mut workers: Vec<(usize, mpsc::UnboundedSender>)>, ) -> (mio::SetReadiness, sync_mpsc::Sender) { @@ -892,8 +891,8 @@ fn start_accept_thread( }, CMD => match rx.try_recv() { Ok(cmd) => match cmd { - Command::Pause => if let Some(server) = server.take() { - if let Err(err) = poll.deregister(&server) { + Command::Pause => if let Some(ref server) = server { + if let Err(err) = poll.deregister(server) { error!( "Can not deregister server socket {}", err @@ -906,15 +905,6 @@ fn start_accept_thread( } }, 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 Err(err) = poll.register( server, diff --git a/src/server/worker.rs b/src/server/worker.rs index 012acd6e..f045074d 100644 --- a/src/server/worker.rs +++ b/src/server/worker.rs @@ -239,9 +239,9 @@ impl StreamHandlerType { match *self { StreamHandlerType::Normal => "http", #[cfg(feature = "tls")] - StreamHandlerType::Tls(ref acceptor) => "https", + StreamHandlerType::Tls(_) => "https", #[cfg(feature = "alpn")] - StreamHandlerType::Alpn(ref acceptor) => "https", + StreamHandlerType::Alpn(_) => "https", } } }