Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions noq-proto/proptest-regressions/tests/proptests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ cc 91184c7b6b718961d2dc03365f02098a18ac0035ca85b95654fbafa430d93664 # shrinks to
cc ec5baef3027436b012a332a97d46814ed157f259337c3f651bbb7a3233bd9c7f # shrinks to input = _RandomInteractionWithMultipathSimpleRoutingArgs { seed: [121, 74, 209, 215, 123, 149, 7, 227, 67, 200, 91, 12, 216, 81, 208, 77, 83, 181, 39, 2, 207, 186, 233, 211, 254, 178, 230, 22, 100, 197, 215, 43], interactions: [Drive { side: Client }, ClosePath { side: Client, path_idx: 0, error_code: 0 }] }
cc b1429b84bf576bb9000e8d0d6d53cff4c93efacf033c9df898aeb9856d1b03fe # shrinks to input = _RandomInteractionWithMultipathSimpleRoutingArgs { seed: [159, 14, 107, 252, 130, 4, 190, 131, 86, 208, 127, 29, 140, 30, 55, 65, 242, 192, 2, 158, 40, 51, 110, 116, 46, 139, 156, 165, 64, 109, 33, 62], interactions: [PassiveMigration { side: Server, addr_idx: 0 }, OpenPath { side: Client, status: Available, addr_idx: 0 }] }
cc 4f717acb71d562f33601dfc8c7fbcca89b13c8259676a20ffc764a92e3ea07a1 # shrinks to input = _RandomInteractionWithMultipathComplexRoutingArgs { seed: [84, 97, 201, 172, 244, 139, 252, 60, 222, 107, 135, 245, 103, 45, 188, 138, 26, 198, 1, 97, 144, 22, 42, 228, 19, 154, 45, 135, 222, 137, 231, 16], interactions: [PassiveMigration { side: Server, addr_idx: 0 }, OpenPath { side: Client, status: Available, addr_idx: 0 }, ClosePath { side: Client, path_idx: 0, error_code: 0 }, PathSetStatus { side: Server, path_idx: 0, status: Backup }], routes: RoutingTable { client_routes: [([::ffff:1.1.1.0]:44433, 0)], server_routes: [([::ffff:2.2.2.0]:4433, 0)] } }
cc e5068a25dcc49304a9afb3ff2bb0b62f9c6f6ca4370dae0b6bfa79e109592345 # shrinks to input = _RandomInteractionArgs { setup: PairSetup { seed: Zeroes, extensions: MultipathOnly, mtud_enabled: true, routing_setup: SimpleSymmetric }, establishment: Full, interactions: [PassiveMigration { side: Server, addr_idx: 0 }, PathSetStatus { side: Client, path_idx: 0, status: Backup }, DriveBothToIdle, OpenPath { side: Client, status: Backup, addr_idx: 0 }] }
27 changes: 19 additions & 8 deletions noq-proto/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::{
qlog::{QlogRecvPacket, QlogSink},
spaces::LostPacket,
stats::PathStatsMap,
timer::{ConnTimer, PathTimer},
timer::{ConnTimer, PathTimer, Timer, TimerTable},
},
crypto::{self, Keys},
frame::{
Expand Down Expand Up @@ -102,8 +102,7 @@ pub use streams::{
ShouldTransmit, StreamEvent, Streams, WriteError,
};

mod timer;
use timer::{Timer, TimerTable};
pub(crate) mod timer;

mod transmit_buf;
use transmit_buf::TransmitBuf;
Expand Down Expand Up @@ -458,6 +457,12 @@ impl Connection {
self.timers.peek()
}

/// Returns the unhandled timers that would expire at given instant.
#[cfg(test)]
pub(crate) fn peek_expiring_timers(&self, now: Instant) -> Vec<Timer> {
self.timers.timers_before(now)
}

/// Returns application-facing events
///
/// Connections should be polled for events after:
Expand Down Expand Up @@ -3804,6 +3809,7 @@ impl Connection {
.stop(Timer::Conn(ConnTimer::Idle), self.qlog.with_time(now));
} else {
let dt = cmp::max(timeout, 3 * self.max_pto_for_space(space));
trace!(?dt, "setting idle timer");
self.timers.set(
Timer::Conn(ConnTimer::Idle),
now + dt,
Expand Down Expand Up @@ -6810,9 +6816,13 @@ impl Connection {
.saturating_sub(path.in_flight.bytes)
}

/// Whether no timers but keepalive, idle, rtt, pushnewcid, and key discard are running
/// Which timer keeps this connection from being idle right now.
///
/// Idle in this case means the next thing that would happen on this
/// connection (unless other traffic is received) would be the connection just sending
/// more keep alives, CIDs, key updates or outright closing due to idle.
#[cfg(test)]
pub(crate) fn is_idle(&self) -> bool {
pub(crate) fn non_idle_timer(&self) -> Option<Timer> {
let current_timers = self.timers.values();
current_timers
.into_iter()
Expand All @@ -6826,12 +6836,13 @@ impl Connection {
)
})
.min_by_key(|(_, time)| *time)
.is_none_or(|(timer, _)| {
matches!(
timer,
.filter(|(next_timer, _)| {
!matches!(
next_timer,
Timer::Conn(ConnTimer::Idle) | Timer::PerPath(_, PathTimer::PathIdle)
)
})
.map(|(timer, _time)| timer)
}

/// Whether explicit congestion notification is in use on outgoing packets.
Expand Down
25 changes: 25 additions & 0 deletions noq-proto/src/connection/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,31 @@ impl TimerTable {

values
}

#[cfg(test)]
pub(crate) fn timers_before(&self, now: Instant) -> Vec<Timer> {
let mut values = Vec::new();

for timer in ConnTimer::VALUES {
if let Some(time) = self.generic[timer as usize]
&& time <= now
{
values.push(Timer::Conn(timer));
}
}

for timer in PathTimer::VALUES {
for (path_id, timers) in self.path_timers.iter() {
if let Some(time) = timers.timers[timer as usize]
&& time <= now
{
values.push(Timer::PerPath(*path_id, timer));
}
}
}

values
}
}

#[cfg(test)]
Expand Down
Loading
Loading