File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
quinn-proto/src/connection Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -1712,8 +1712,6 @@ impl Connection {
17121712 let rtt = self . path . rtt . conservative ( ) ;
17131713 let loss_delay = cmp:: max ( rtt. mul_f32 ( self . config . time_threshold ) , TIMER_GRANULARITY ) ;
17141714
1715- // Packets sent before this time are deemed lost.
1716- let lost_send_time = now. checked_sub ( loss_delay) . unwrap ( ) ;
17171715 let largest_acked_packet = self . spaces [ pn_space] . largest_acked_packet . unwrap ( ) ;
17181716 let packet_threshold = self . config . packet_threshold as u64 ;
17191717 let mut size_of_lost_packets = 0u64 ;
@@ -1737,8 +1735,11 @@ impl Connection {
17371735 persistent_congestion_start = None ;
17381736 }
17391737
1740- if info. time_sent <= lost_send_time || largest_acked_packet >= packet + packet_threshold
1741- {
1738+ // Packets sent before now - loss_delay are deemed lost.
1739+ // However, we avoid this subtraction as it can panic and there's no
1740+ // saturating equivalent of this substraction operation with a Duration.
1741+ let packet_too_old = now. saturating_duration_since ( info. time_sent ) >= loss_delay;
1742+ if packet_too_old || largest_acked_packet >= packet + packet_threshold {
17421743 if Some ( packet) == in_flight_mtu_probe {
17431744 // Lost MTU probes are not included in `lost_packets`, because they should not
17441745 // trigger a congestion control response
You can’t perform that action at this time.
0 commit comments