Skip to content

Commit

Permalink
Fix graceful shutdown for Http(1|2)Builder
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
k0nserv committed Jan 16, 2024
1 parent 55b5171 commit e4e3f01
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/server/conn/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ impl<E> Http1Builder<'_, E> {
}

/// Bind a connection together with a [`Service`].
pub async fn serve_connection<I, S, B>(&self, io: I, service: S) -> Result<()>
pub fn serve_connection<I, S, B>(&self, io: I, service: S) -> Connection<I, S, E>
where
S: Service<Request<Incoming>, Response = Response<B>>,
S::Future: 'static,
Expand All @@ -532,7 +532,7 @@ impl<E> Http1Builder<'_, E> {
I: Read + Write + Unpin + 'static,
E: Http2ServerConnExec<S::Future, B>,
{
self.inner.serve_connection(io, service).await
self.inner.serve_connection(io, service)
}
}

Expand Down Expand Up @@ -667,7 +667,7 @@ impl<E> Http2Builder<'_, E> {
}

/// Bind a connection together with a [`Service`].
pub async fn serve_connection<I, S, B>(&self, io: I, service: S) -> Result<()>
pub fn serve_connection<I, S, B>(&self, io: I, service: S) -> Connection<I, S, E>
where
S: Service<Request<Incoming>, Response = Response<B>>,
S::Future: 'static,
Expand All @@ -677,7 +677,7 @@ impl<E> Http2Builder<'_, E> {
I: Read + Write + Unpin + 'static,
E: Http2ServerConnExec<S::Future, B>,
{
self.inner.serve_connection(io, service).await
self.inner.serve_connection(io, service)
}
}

Expand Down

0 comments on commit e4e3f01

Please sign in to comment.