From adc41e4b2dbfd712985bf06b3fe49995ee76eafd Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Tue, 22 Jan 2019 17:49:17 -0800 Subject: [PATCH] Upper bound to PTO interval Prevents overflow and improves worst-case latency on erratic links with high idle timeouts. --- quinn-proto/src/connection.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/quinn-proto/src/connection.rs b/quinn-proto/src/connection.rs index f1a947cbd..53b6c0049 100644 --- a/quinn-proto/src/connection.rs +++ b/quinn-proto/src/connection.rs @@ -685,8 +685,10 @@ impl Connection { } // Calculate PTO duration + const MAX_PTO_EXPONENT: u32 = 24; // 2^24μs = ~17 seconds let timeout = self.rtt.smoothed + 4 * self.rtt.var + self.max_ack_delay(); - let timeout = cmp::max(timeout, TIMER_GRANULARITY) * 2u64.pow(self.pto_count); + let timeout = cmp::max(timeout, TIMER_GRANULARITY) + * 2u64.pow(cmp::min(self.pto_count, MAX_PTO_EXPONENT)); self.io.timer_start( Timer::LossDetection, self.time_of_last_sent_ack_eliciting_packet + timeout,