Skip to content

Commit e4e3f01

Browse files
committed
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.
1 parent 55b5171 commit e4e3f01

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/server/conn/auto.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ impl<E> Http1Builder<'_, E> {
522522
}
523523

524524
/// Bind a connection together with a [`Service`].
525-
pub async fn serve_connection<I, S, B>(&self, io: I, service: S) -> Result<()>
525+
pub fn serve_connection<I, S, B>(&self, io: I, service: S) -> Connection<I, S, E>
526526
where
527527
S: Service<Request<Incoming>, Response = Response<B>>,
528528
S::Future: 'static,
@@ -532,7 +532,7 @@ impl<E> Http1Builder<'_, E> {
532532
I: Read + Write + Unpin + 'static,
533533
E: Http2ServerConnExec<S::Future, B>,
534534
{
535-
self.inner.serve_connection(io, service).await
535+
self.inner.serve_connection(io, service)
536536
}
537537
}
538538

@@ -667,7 +667,7 @@ impl<E> Http2Builder<'_, E> {
667667
}
668668

669669
/// Bind a connection together with a [`Service`].
670-
pub async fn serve_connection<I, S, B>(&self, io: I, service: S) -> Result<()>
670+
pub fn serve_connection<I, S, B>(&self, io: I, service: S) -> Connection<I, S, E>
671671
where
672672
S: Service<Request<Incoming>, Response = Response<B>>,
673673
S::Future: 'static,
@@ -677,7 +677,7 @@ impl<E> Http2Builder<'_, E> {
677677
I: Read + Write + Unpin + 'static,
678678
E: Http2ServerConnExec<S::Future, B>,
679679
{
680-
self.inner.serve_connection(io, service).await
680+
self.inner.serve_connection(io, service)
681681
}
682682
}
683683

0 commit comments

Comments
 (0)