1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-26 11:31:09 +00:00

Fixed panic during graceful shutdown

This commit is contained in:
Nikolay Kim 2018-10-09 11:35:57 -07:00
parent c3ad516f56
commit 65e9201b4d
3 changed files with 28 additions and 21 deletions

View file

@ -1,5 +1,12 @@
# Changes # Changes
## [0.7.10] - 2018-10-09
### Fixed
* Fixed panic during graceful shutdown
## [0.7.9] - 2018-10-09 ## [0.7.9] - 2018-10-09
### Added ### Added

View file

@ -9,7 +9,7 @@ use tokio_reactor::Handle;
use tokio_tcp::TcpStream; use tokio_tcp::TcpStream;
use tokio_timer::{sleep, Delay}; use tokio_timer::{sleep, Delay};
use super::channel::HttpProtocol; // use super::channel::HttpProtocol;
use super::error::AcceptorError; use super::error::AcceptorError;
use super::handler::HttpHandler; use super::handler::HttpHandler;
use super::settings::ServiceConfig; use super::settings::ServiceConfig;
@ -367,9 +367,9 @@ where
} }
ServerMessage::Shutdown(_) => Either::B(ok(())), ServerMessage::Shutdown(_) => Either::B(ok(())),
ServerMessage::ForceShutdown => { ServerMessage::ForceShutdown => {
self.settings // self.settings
.head() // .head()
.traverse(|proto: &mut HttpProtocol<TcpStream, H>| proto.shutdown()); // .traverse(|proto: &mut HttpProtocol<TcpStream, H>| proto.shutdown());
Either::B(ok(())) Either::B(ok(()))
} }
} }

View file

@ -20,23 +20,23 @@ pub(crate) enum HttpProtocol<T: IoStream, H: HttpHandler + 'static> {
None, None,
} }
impl<T: IoStream, H: HttpHandler + 'static> HttpProtocol<T, H> { // impl<T: IoStream, H: HttpHandler + 'static> HttpProtocol<T, H> {
pub(crate) fn shutdown(&mut self) { // fn shutdown_(&mut self) {
match self { // match self {
HttpProtocol::H1(ref mut h1) => { // HttpProtocol::H1(ref mut h1) => {
let io = h1.io(); // let io = h1.io();
let _ = IoStream::set_linger(io, Some(time::Duration::new(0, 0))); // let _ = IoStream::set_linger(io, Some(time::Duration::new(0, 0)));
let _ = IoStream::shutdown(io, Shutdown::Both); // let _ = IoStream::shutdown(io, Shutdown::Both);
} // }
HttpProtocol::H2(ref mut h2) => h2.shutdown(), // HttpProtocol::H2(ref mut h2) => h2.shutdown(),
HttpProtocol::Unknown(_, io, _) => { // HttpProtocol::Unknown(_, io, _) => {
let _ = IoStream::set_linger(io, Some(time::Duration::new(0, 0))); // let _ = IoStream::set_linger(io, Some(time::Duration::new(0, 0)));
let _ = IoStream::shutdown(io, Shutdown::Both); // let _ = IoStream::shutdown(io, Shutdown::Both);
} // }
HttpProtocol::None => (), // HttpProtocol::None => (),
} // }
} // }
} // }
enum ProtocolKind { enum ProtocolKind {
Http1, Http1,