diff --git a/src/server.rs b/src/server.rs index e98c06c9..12cca0ef 100644 --- a/src/server.rs +++ b/src/server.rs @@ -393,10 +393,10 @@ async fn process_stream( } let stream = RewindStream::new(leftover, stream); // Hand the connection to the application for processing. + // We already run `process_stream` inside a task, so spawning again + // only adds overhead. let app = (factory)(); - tokio::spawn(async move { - app.handle_connection(stream).await; - }); + app.handle_connection(stream).await; } Err(err) => { if let Some(handler) = on_failure.as_ref() {