From 65e9201b4d586df303b7d0870cdb55a107d0327b Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 9 Oct 2018 11:35:57 -0700 Subject: [PATCH] Fixed panic during graceful shutdown --- CHANGES.md | 7 +++++++ src/server/acceptor.rs | 8 ++++---- src/server/channel.rs | 34 +++++++++++++++++----------------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f4f665a86..46f1fb367 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,12 @@ # Changes +## [0.7.10] - 2018-10-09 + +### Fixed + +* Fixed panic during graceful shutdown + + ## [0.7.9] - 2018-10-09 ### Added diff --git a/src/server/acceptor.rs b/src/server/acceptor.rs index 2e1b1f283..a18dded9b 100644 --- a/src/server/acceptor.rs +++ b/src/server/acceptor.rs @@ -9,7 +9,7 @@ use tokio_reactor::Handle; use tokio_tcp::TcpStream; use tokio_timer::{sleep, Delay}; -use super::channel::HttpProtocol; +// use super::channel::HttpProtocol; use super::error::AcceptorError; use super::handler::HttpHandler; use super::settings::ServiceConfig; @@ -367,9 +367,9 @@ where } ServerMessage::Shutdown(_) => Either::B(ok(())), ServerMessage::ForceShutdown => { - self.settings - .head() - .traverse(|proto: &mut HttpProtocol| proto.shutdown()); + // self.settings + // .head() + // .traverse(|proto: &mut HttpProtocol| proto.shutdown()); Either::B(ok(())) } } diff --git a/src/server/channel.rs b/src/server/channel.rs index 1f4ec5b19..af90d9346 100644 --- a/src/server/channel.rs +++ b/src/server/channel.rs @@ -20,23 +20,23 @@ pub(crate) enum HttpProtocol { None, } -impl HttpProtocol { - pub(crate) fn shutdown(&mut self) { - match self { - HttpProtocol::H1(ref mut h1) => { - let io = h1.io(); - let _ = IoStream::set_linger(io, Some(time::Duration::new(0, 0))); - let _ = IoStream::shutdown(io, Shutdown::Both); - } - HttpProtocol::H2(ref mut h2) => h2.shutdown(), - HttpProtocol::Unknown(_, io, _) => { - let _ = IoStream::set_linger(io, Some(time::Duration::new(0, 0))); - let _ = IoStream::shutdown(io, Shutdown::Both); - } - HttpProtocol::None => (), - } - } -} +// impl HttpProtocol { +// fn shutdown_(&mut self) { +// match self { +// HttpProtocol::H1(ref mut h1) => { +// let io = h1.io(); +// let _ = IoStream::set_linger(io, Some(time::Duration::new(0, 0))); +// let _ = IoStream::shutdown(io, Shutdown::Both); +// } +// HttpProtocol::H2(ref mut h2) => h2.shutdown(), +// HttpProtocol::Unknown(_, io, _) => { +// let _ = IoStream::set_linger(io, Some(time::Duration::new(0, 0))); +// let _ = IoStream::shutdown(io, Shutdown::Both); +// } +// HttpProtocol::None => (), +// } +// } +// } enum ProtocolKind { Http1,