From c2e9cc6c2a8a11219e18bed59e10edba9bc424a3 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Wed, 10 Jul 2019 09:35:14 -0700 Subject: [PATCH] Acknowledge close This allows peers to enter the draining state immediately, which could reduce resource use. --- quinn-proto/src/connection.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/quinn-proto/src/connection.rs b/quinn-proto/src/connection.rs index de7b8679d..c3db90ccc 100644 --- a/quinn-proto/src/connection.rs +++ b/quinn-proto/src/connection.rs @@ -1638,6 +1638,7 @@ where Frame::Close(reason) => { self.events.push_back(ConnectionError::from(reason).into()); self.state = State::Draining; + self.io.close = true; return Ok(()); } Frame::PathChallenge(token) => { @@ -1984,10 +1985,10 @@ where } let (spaces, close) = match self.state { - State::Draining | State::Drained => { + State::Drained => { return None; } - State::Closed(_) => { + State::Draining | State::Closed(_) => { if mem::replace(&mut self.io.close, false) { (vec![self.highest_space], true) } else { @@ -2106,6 +2107,12 @@ where - space.crypto.as_ref().unwrap().packet.tag_len(); match self.state { State::Closed(state::Closed { ref reason }) => reason.encode(&mut buf, max_len), + State::Draining => frame::ConnectionClose { + error_code: TransportErrorCode::NO_ERROR, + frame_type: None, + reason: Bytes::new(), + } + .encode(&mut buf, max_len), _ => unreachable!( "tried to make a close packet when the connection wasn't closed" ),