From fce3ddce4671e7df439a9d8fdc469b079fc07318 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Tue, 24 Mar 2020 17:41:36 -0700 Subject: [PATCH] fix(server): fix panic in Connection::graceful_shutdown --- src/server/conn.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/server/conn.rs b/src/server/conn.rs index 74bb18dbfc..aa8233da46 100644 --- a/src/server/conn.rs +++ b/src/server/conn.rs @@ -502,14 +502,21 @@ where /// /// This `Connection` should continue to be polled until shutdown /// can finish. + /// + /// # Note + /// + /// This should only be called while the `Connection` future is still + /// pending. If called after `Connection::poll` has resolved, this does + /// nothing. pub fn graceful_shutdown(self: Pin<&mut Self>) { - match self.project().conn.as_mut().unwrap() { - ProtoServer::H1(ref mut h1) => { + match self.project().conn { + Some(ProtoServer::H1(ref mut h1)) => { h1.disable_keep_alive(); } - ProtoServer::H2(ref mut h2) => { + Some(ProtoServer::H2(ref mut h2)) => { h2.graceful_shutdown(); } + None => (), } }