From e4e3f01576200a9abaabcec31f8a4c5fe783b9cf Mon Sep 17 00:00:00 2001 From: Hugo Tunius Date: Tue, 16 Jan 2024 17:38:32 +0000 Subject: [PATCH] Fix graceful shutdown for Http(1|2)Builder Because `Http1Builder::serve_connection` and `Http2Builder::serve_connection` didn't return `Connection` it was impossible to use them in combination with `Connection::graceful_shutdown`. By returning the Connection future rather than awaiting it, this becomes possible. --- src/server/conn/auto.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server/conn/auto.rs b/src/server/conn/auto.rs index fa5337a..e18bb65 100644 --- a/src/server/conn/auto.rs +++ b/src/server/conn/auto.rs @@ -522,7 +522,7 @@ impl Http1Builder<'_, E> { } /// Bind a connection together with a [`Service`]. - pub async fn serve_connection(&self, io: I, service: S) -> Result<()> + pub fn serve_connection(&self, io: I, service: S) -> Connection where S: Service, Response = Response>, S::Future: 'static, @@ -532,7 +532,7 @@ impl Http1Builder<'_, E> { I: Read + Write + Unpin + 'static, E: Http2ServerConnExec, { - self.inner.serve_connection(io, service).await + self.inner.serve_connection(io, service) } } @@ -667,7 +667,7 @@ impl Http2Builder<'_, E> { } /// Bind a connection together with a [`Service`]. - pub async fn serve_connection(&self, io: I, service: S) -> Result<()> + pub fn serve_connection(&self, io: I, service: S) -> Connection where S: Service, Response = Response>, S::Future: 'static, @@ -677,7 +677,7 @@ impl Http2Builder<'_, E> { I: Read + Write + Unpin + 'static, E: Http2ServerConnExec, { - self.inner.serve_connection(io, service).await + self.inner.serve_connection(io, service) } }