fix(http2): implement graceful_shutdown for HTTP2 server connections

Closes #1550
This commit is contained in:
Sean McArthur
2018-06-06 13:00:59 -07:00
parent 3affe2a0af
commit b7a0c2d596

View File

@@ -26,6 +26,7 @@ where
{
Handshaking(Handshake<T, SendBuf<B::Data>>),
Serving(Serving<T, B>),
Closed,
}
struct Serving<T, B>
@@ -55,7 +56,20 @@ where
}
pub fn graceful_shutdown(&mut self) {
unimplemented!("h2 server graceful shutdown");
trace!("graceful_shutdown");
match self.state {
State::Handshaking(..) => {
// fall-through, to replace state with Closed
},
State::Serving(ref mut srv) => {
srv.conn.graceful_shutdown();
return;
},
State::Closed => {
return;
}
}
self.state = State::Closed;
}
}
@@ -82,6 +96,11 @@ where
State::Serving(ref mut srv) => {
return srv.poll_server(&mut self.service, &self.exec);
}
State::Closed => {
// graceful_shutdown was called before handshaking finished,
// nothing to do here...
return Ok(Async::Ready(()));
}
};
self.state = next;
}