diff --git a/quinn-proto/src/connection.rs b/quinn-proto/src/connection.rs index 26f3ed0ab..1c4fa9792 100644 --- a/quinn-proto/src/connection.rs +++ b/quinn-proto/src/connection.rs @@ -2871,21 +2871,7 @@ impl Connection { debug_assert!(self.side.is_client()); debug!(self.log, "0-RTT rejected"); self.accepted_0rtt = false; - // Reset all outgoing streams - for i in 0..self.streams.next_bi { - self.streams - .streams - .remove(&StreamId::new(self.side, Directionality::Bi, i)) - .unwrap(); - } - self.streams.next_bi = 0; - for i in 0..self.streams.next_uni { - self.streams - .streams - .remove(&StreamId::new(self.side, Directionality::Uni, i)) - .unwrap(); - } - self.streams.next_uni = 0; + self.streams.reset(self.side); // Discard already-queued frames self.space_mut(SpaceId::Data).pending = Retransmits::default(); // Discard 0-RTT packets diff --git a/quinn-proto/src/stream.rs b/quinn-proto/src/stream.rs index 893ba0261..06d009603 100644 --- a/quinn-proto/src/stream.rs +++ b/quinn-proto/src/stream.rs @@ -88,6 +88,22 @@ impl Streams { } } + pub fn reset(&mut self, side: Side) { + // Reset all outgoing streams + for i in 0..self.next_bi { + self.streams + .remove(&StreamId::new(side, Directionality::Bi, i)) + .unwrap(); + } + self.next_bi = 0; + for i in 0..self.next_uni { + self.streams + .remove(&StreamId::new(side, Directionality::Uni, i)) + .unwrap(); + } + self.next_uni = 0; + } + pub fn read(&mut self, id: StreamId, buf: &mut [u8]) -> Result<(usize, bool), ReadError> { let rs = self.get_recv_mut(id).ok_or(ReadError::UnknownStream)?; Ok((rs.read(buf)?, rs.receiving_unknown_size()))