From e0f224b848e725f94e7c9050ca1dfec16eb39bd8 Mon Sep 17 00:00:00 2001 From: Cameron Bytheway Date: Thu, 18 Apr 2024 15:18:42 -0600 Subject: [PATCH] feat(s2n-quic-core): allow forced PTO transmissions (#2130) * feat(s2n-quic-core): allow forced PTO transmissions * rename to on_transmit_once and use in on_transmit --------- Co-authored-by: Wesley Rosenblum --- quic/s2n-quic-core/src/recovery/pto.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/quic/s2n-quic-core/src/recovery/pto.rs b/quic/s2n-quic-core/src/recovery/pto.rs index 95d6ef4cf0..ee4f3ce9a1 100644 --- a/quic/s2n-quic-core/src/recovery/pto.rs +++ b/quic/s2n-quic-core/src/recovery/pto.rs @@ -71,6 +71,17 @@ impl Pto { pub fn transmissions(&self) -> u8 { self.state.transmissions() } + + #[inline] + pub fn on_transmit_once(&mut self) { + self.state.on_transmit(); + } + + #[inline] + pub fn force_transmit(&mut self) { + ensure!(matches!(self.state, State::Idle)); + self.state = State::RequiresTransmission(1); + } } impl timer::Provider for Pto { @@ -120,7 +131,7 @@ impl transmission::Provider for Pto { // The early transmission will automatically ensure all initial packets sent by the // client are padded to 1200 bytes - self.state.on_transmit(); + self.on_transmit_once(); } }