Skip to content

Commit

Permalink
rtt: initialize min_rtt to zero
Browse files Browse the repository at this point in the history
Follow-up to 3b758cb which changed the
initial min_rtt value from Duration::ZERO to Duration::MAX.

This could potentially cause an overflow, for example if there is no
previous RTT sample, and the CUBIC congestion avoidance logic is
triggered.

Switch back the initial value to ZERO.
  • Loading branch information
ghedo committed May 13, 2024
1 parent a9b3954 commit f29db19
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions quiche/src/recovery/rtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl RttStats {
pub(crate) fn new(max_ack_delay: Duration) -> Self {
RttStats {
latest_rtt: Duration::ZERO,
min_rtt: Minmax::new(Duration::MAX),
min_rtt: Minmax::new(Duration::ZERO),
smoothed_rtt: INITIAL_RTT,
rttvar: INITIAL_RTT / 2,
first_rtt_sample: None,
Expand Down Expand Up @@ -114,6 +114,6 @@ impl RttStats {
}

pub(crate) fn min_rtt(&self) -> Option<Duration> {
self.min_rtt.ne(&Duration::MAX).then_some(*self.min_rtt)
self.min_rtt.ne(&Duration::ZERO).then_some(*self.min_rtt)
}
}

0 comments on commit f29db19

Please sign in to comment.