1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-27 03:51:10 +00:00

set socket linger to 0 on timeout

This commit is contained in:
Nikolay Kim 2018-10-01 20:53:22 -07:00
parent 1bac65de4c
commit e4686f6c8d

View file

@ -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");