Add Graceful Shutdown support
If graceful shutdown is initiated, a GOAWAY of the max stream ID - 1 is sent, followed by a PING frame, to measure RTT. When the PING is ACKed, the connection sends a new GOAWAY with the proper last processed stream ID. From there, once all active streams have completely, the connection will finally close.
This commit is contained in:
@@ -11,8 +11,18 @@ pub struct Ping {
|
||||
payload: Payload,
|
||||
}
|
||||
|
||||
// This was just 8 randomly generated bytes. We use something besides just
|
||||
// zeroes to distinguish this specific PING from any other.
|
||||
const SHUTDOWN_PAYLOAD: Payload = [0x0b, 0x7b, 0xa2, 0xf0, 0x8b, 0x9b, 0xfe, 0x54];
|
||||
|
||||
impl Ping {
|
||||
|
||||
#[cfg(feature = "unstable")]
|
||||
pub const SHUTDOWN: Payload = SHUTDOWN_PAYLOAD;
|
||||
|
||||
#[cfg(not(feature = "unstable"))]
|
||||
pub(crate) const SHUTDOWN: Payload = SHUTDOWN_PAYLOAD;
|
||||
|
||||
pub fn new(payload: Payload) -> Ping {
|
||||
Ping {
|
||||
ack: false,
|
||||
@@ -31,7 +41,6 @@ impl Ping {
|
||||
self.ack
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable")]
|
||||
pub fn payload(&self) -> &Payload {
|
||||
&self.payload
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user