diff --git a/src/server/h1.rs b/src/server/h1.rs index f5e2bf2f5..433a916b0 100644 --- a/src/server/h1.rs +++ b/src/server/h1.rs @@ -1,6 +1,6 @@ use std::collections::VecDeque; -use std::net::SocketAddr; -use std::time::Instant; +use std::net::{Shutdown, SocketAddr}; +use std::time::{Duration, Instant}; use bytes::BytesMut; use futures::{Async, Future, Poll}; @@ -239,6 +239,12 @@ where if self.tasks.is_empty() { // if we get timer during shutdown, just drop connection if self.flags.contains(Flags::SHUTDOWN) { + let io = self.stream.get_mut(); + let _ = IoStream::set_linger( + io, + Some(Duration::from_secs(0)), + ); + let _ = IoStream::shutdown(io, Shutdown::Both); return Err(HttpDispatchError::ShutdownTimeout); } else { trace!("Keep-alive timeout, close connection");