Skip to content

Commit 104ad13

Browse files
committed
fix: avoid panic of graceful shutdown for finished connection
fixes #3615
1 parent bc9a86f commit 104ad13

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/server/conn/http1.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,11 @@ where
482482
/// This `Connection` should continue to be polled until shutdown
483483
/// can finish.
484484
pub fn graceful_shutdown(mut self: Pin<&mut Self>) {
485-
Pin::new(self.inner.as_mut().unwrap()).graceful_shutdown()
485+
// Connection (`inner`) is `None` if `poll` is `Ready`.
486+
// In that case, we don't need to call `graceful_shutdown`.
487+
if let Some(conn) = self.inner.as_mut() {
488+
Pin::new(conn).graceful_shutdown()
489+
}
486490
}
487491
}
488492

0 commit comments

Comments
 (0)