Skip to content
Merged
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
23 changes: 0 additions & 23 deletions quest/m1/resume-owed-wake.md

This file was deleted.

51 changes: 51 additions & 0 deletions rs/moq-net/src/model/resume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,14 @@ impl Reader {
if !deliverable || !self.window().contains(key) {
// Skipping an ordered cursor past a group the window still owes below
// would lose it, though it may yet land on this copy: leave it there.
// The peek returned the held group, so only the copy's arrivals wake
// the read when the owed one lands: one already landed is peeked again.
if ordered && deliverable && self.owes_below(floor, key, delivered) {
let copy = &self.copies[index];
if copy.track.poll_arrived(arrivals, waiter).is_ready() {
arrivals = copy.track.arrived();
continue;
}
break;
}
let Sub::Ready(sub) = &mut self.copies[index].sub else {
Expand Down Expand Up @@ -6016,6 +6023,50 @@ mod test {
assert_eq!(drain(&mut sub, true), [0, 10, 11]);
}

/// A key-order read holding a copy's cursor on a group outside its window, for a group the
/// window still owes below it, wakes when that group lands on the copy.
#[test]
#[cfg(feature = "async")]
fn a_key_order_read_holding_a_copy_wakes_when_the_owed_group_lands() {
let routes = Producer::new();
let logical = logical(&routes);
let a = received_copy();
write(&a, 10);
routes.serve(a.consume());
let from_ten = track::Range {
start: track::Anchor::Time(10),
end: None,
};
let subscription = Subscription::default()
.with_delay(Delay::default().with_max(HOUR))
.with_ranges([track::Range::groups(0..1), from_ten]);
let mut sub = logical
.consume()
.subscribe(subscription)
.now_or_never()
.unwrap()
.unwrap();
// a places the window at 0 and from 10; the cap holds 10 back.
sub.set_range(..10);
assert!(drain(&mut sub, true).is_empty());

// b holds 5 but not 10, so it places the second range at 5, and 0 is owed below it.
let b = received_copy();
write(&b, 5);
routes.serve(b.consume());
let wake = Arc::new(Wake::default());
let waiter = kio::Waiter::new(wake.clone().into());
assert!(sub.poll_next_group(&waiter).is_pending());
wake.0.store(false, std::sync::atomic::Ordering::Relaxed);
write(&b, 0);
assert!(wake.0.load(std::sync::atomic::Ordering::Relaxed));
// The same task's read hands it out, not the idle answer it parked with.
let Poll::Ready(Ok(Some(group))) = sub.poll_next_group(&waiter) else {
panic!("the owed group is handed out")
};
assert_eq!(group.start, 0);
}

#[test]
fn ordered_replay_skips_unbounded_copies_while_a_nested_route_waits() {
for nested in [false, true] {
Expand Down