From d4264c1477345e7782227002951155d8cc09dbd1 Mon Sep 17 00:00:00 2001 From: Shreyan Date: Thu, 15 Jan 2026 20:10:18 +0000 Subject: [PATCH] fix unused() method to properly check sent packets --- quiche/src/path.rs | 10 ++++++---- quiche/src/recovery/congestion/recovery.rs | 6 +++++- quiche/src/recovery/gcongestion/recovery.rs | 3 +++ quiche/src/recovery/mod.rs | 4 +++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/quiche/src/path.rs b/quiche/src/path.rs index b950bda9ab..31603d867f 100644 --- a/quiche/src/path.rs +++ b/quiche/src/path.rs @@ -324,11 +324,13 @@ impl Path { /// Returns whether the path is unused. #[inline] - fn unused(&self) -> bool { - // FIXME: we should check that there is nothing in the sent queue. - !self.active() && self.active_dcid_seq.is_none() + fn unused(&self) -> bool { + // FIXME: we should check that there is nothing in the sent queue. + !self.active() && + self.active_dcid_seq.is_none() && + self.recovery.bytes_in_flight_duration() == Duration::ZERO && + self.recovery.sent_packets_empty() } - /// Returns whether the path requires sending a probing packet. #[inline] pub fn probing_required(&self) -> bool { diff --git a/quiche/src/recovery/congestion/recovery.rs b/quiche/src/recovery/congestion/recovery.rs index 2c72d80725..2136727200 100644 --- a/quiche/src/recovery/congestion/recovery.rs +++ b/quiche/src/recovery/congestion/recovery.rs @@ -625,7 +625,6 @@ impl RecoveryOps for LegacyRecovery { } self.epochs[epoch].sent_packets.push_back(pkt); - trace!("{trace_id} {self:?}"); } @@ -1064,6 +1063,10 @@ impl RecoveryOps for LegacyRecovery { fn bytes_lost(&self) -> u64 { self.bytes_lost } + + fn sent_packets_empty(&self) -> bool { + self.epochs.iter().all(|epoch| epoch.sent_packets.is_empty()) + } } impl std::fmt::Debug for LegacyRecovery { @@ -1114,3 +1117,4 @@ pub struct Acked { pub is_app_limited: bool, } + diff --git a/quiche/src/recovery/gcongestion/recovery.rs b/quiche/src/recovery/gcongestion/recovery.rs index cde744f4fc..712711a1d1 100644 --- a/quiche/src/recovery/gcongestion/recovery.rs +++ b/quiche/src/recovery/gcongestion/recovery.rs @@ -1169,6 +1169,9 @@ impl RecoveryOps for GRecovery { .min(64 * 1024) .max(floor as u64) as usize } + fn sent_packets_empty(&self) -> bool { + self.epochs.iter().all(|epoch| epoch.sent_packets.is_empty()) + } } impl std::fmt::Debug for GRecovery { diff --git a/quiche/src/recovery/mod.rs b/quiche/src/recovery/mod.rs index c4ec4051fa..5c74dd35ad 100644 --- a/quiche/src/recovery/mod.rs +++ b/quiche/src/recovery/mod.rs @@ -183,7 +183,7 @@ pub struct OnLossDetectionTimeoutOutcome { pub trait RecoveryOps { fn lost_count(&self) -> usize; fn bytes_lost(&self) -> u64; - + /// Returns whether or not we should elicit an ACK even if we wouldn't /// otherwise have constructed an ACK eliciting packet. fn should_elicit_ack(&self, epoch: packet::Epoch) -> bool; @@ -316,6 +316,8 @@ pub trait RecoveryOps { fn get_next_release_time(&self) -> ReleaseDecision; fn gcongestion_enabled(&self) -> bool; + + fn sent_packets_empty(&self) -> bool; } impl Recovery {