Skip to content

Commit

Permalink
fix(http2): implement graceful_shutdown for HTTP2 server connections
Browse files Browse the repository at this point in the history
Closes #1550
  • Loading branch information
seanmonstar committed Jun 6, 2018
1 parent 3affe2a commit b7a0c2d
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/proto/h2/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ where
{
Handshaking(Handshake<T, SendBuf<B::Data>>),
Serving(Serving<T, B>),
Closed,
}

struct Serving<T, B>
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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;
}
Expand Down

0 comments on commit b7a0c2d

Please sign in to comment.