-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
A-serverArea: server.Area: server.B-breaking-changeBlocked: this is an "API breaking change".Blocked: this is an "API breaking change".C-bugCategory: bug. Something is wrong. This is bad!Category: bug. Something is wrong. This is bad!E-mediumEffort: medium. Some knowledge of how hyper internal works would be useful.Effort: medium. Some knowledge of how hyper internal works would be useful.
Milestone
Description
Version
hyper 0.14.16
Platform
Linux DESKTOP-DHO88R7 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Description
If you gracefully shut down a server connection future before the first request, Hyper will not actually shut the connection down until a request is processed:
use hyper::server::conn::Http;
use hyper::Response;
use tokio::io::AsyncReadExt;
use tokio::net::{TcpListener, TcpStream};
use tokio::pin;
#[tokio::main]
async fn main() {
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
let addr = listener.local_addr().unwrap();
tokio::spawn(server(listener));
let mut stream = TcpStream::connect(addr).await.unwrap();
println!("connected");
let mut buf = vec![];
stream.read_to_end(&mut buf).await.unwrap();
}
async fn server(listener: TcpListener) {
let socket = listener.accept().await.unwrap().0;
let service = hyper::service::service_fn(|_: hyper::Request<hyper::Body>| async {
Err::<Response<hyper::Body>, _>("no")
});
let future = Http::new()
.http1_only(true)
.serve_connection(socket, service);
pin!(future);
future.as_mut().graceful_shutdown();
future.await.unwrap();
}
I would expect this program to exit almost instantly since there is no request being processed when the graceful_shutdown is invoked. However, it instead blocks forever waiting on the client to send headers.
The behavior actually appears to be that the shutdown is processed immediately after the first request is fully handled.
Metadata
Metadata
Assignees
Labels
A-serverArea: server.Area: server.B-breaking-changeBlocked: this is an "API breaking change".Blocked: this is an "API breaking change".C-bugCategory: bug. Something is wrong. This is bad!Category: bug. Something is wrong. This is bad!E-mediumEffort: medium. Some knowledge of how hyper internal works would be useful.Effort: medium. Some knowledge of how hyper internal works would be useful.