Skip to content

Commit fce3ddc

Browse files
committed
fix(server): fix panic in Connection::graceful_shutdown
1 parent 597cef2 commit fce3ddc

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/server/conn.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,14 +502,21 @@ where
502502
///
503503
/// This `Connection` should continue to be polled until shutdown
504504
/// can finish.
505+
///
506+
/// # Note
507+
///
508+
/// This should only be called while the `Connection` future is still
509+
/// pending. If called after `Connection::poll` has resolved, this does
510+
/// nothing.
505511
pub fn graceful_shutdown(self: Pin<&mut Self>) {
506-
match self.project().conn.as_mut().unwrap() {
507-
ProtoServer::H1(ref mut h1) => {
512+
match self.project().conn {
513+
Some(ProtoServer::H1(ref mut h1)) => {
508514
h1.disable_keep_alive();
509515
}
510-
ProtoServer::H2(ref mut h2) => {
516+
Some(ProtoServer::H2(ref mut h2)) => {
511517
h2.graceful_shutdown();
512518
}
519+
None => (),
513520
}
514521
}
515522

0 commit comments

Comments
 (0)