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
1 change: 0 additions & 1 deletion quest/m1/security-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,5 @@ Dropped, with reasons:
- [fMP4 import streams mdat](/quest/m1/security-audit/fmp4-stream-mdat.md) - a box header declaring a huge size cannot pin importer memory across segments
- [MKV import streams blocks](/quest/m1/security-audit/mkv-stream-blocks.md) - a declared block, metadata master, or ignored element cannot pin importer memory
- [Relay HTTP surface](/quest/m1/security-audit/relay-http.md) - `/fetch` cannot be sniffed as active content, and no web page can reach the ops listener
- [Lite fetch backstop](/quest/m1/security-audit/fetch-backstop.md) - the pre-lite-05 fetch backstop is bounded by design or by the session's limits, not an unrelated default
- [Browser input checks](/quest/m1/security-audit/js-input.md) - room metadata is schema-validated and the http:// fingerprint fetch is aborted and length-checked
- [CI tool pins](/quest/m1/security-audit/ci-pins.md) - binding generators are pinned by commit in one place, and the remaining unpinned installs and broad token grants are fixed
22 changes: 0 additions & 22 deletions quest/m1/security-audit/fetch-backstop.md

This file was deleted.

85 changes: 31 additions & 54 deletions rs/moq-net/src/lite/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2560,25 +2560,42 @@ mod tests {
);
}

/// A held fill costs one entry, shared by every reader that joins it, until the last leaves.
#[moq_clock::test]
async fn the_feed_track_backstop_refuses_the_next_group() {
async fn held_feed_fills_follow_shared_demand() {
let start = crate::time::Instant::now();
let clock = crate::time::Deadlines::new(start);
let tail = kio::Producer::new(Tail::default());
let sub = feed_sub(&tail).await;
let (track, mut callers, requests) = feed_batch([1, 2, 3]);
let dynamic = track.requests();
let mut fetches = FeedFetches::new(&clock);
fetches.max = 2;
for req in requests {
fetches.push(req, &track.consume());
}
fetches.poll(&sub, start, &kio::Waiter::noop());
assert_eq!(fetches.held.len(), 2);
assert!(matches!(
callers.pop().unwrap().now_or_never(),
Some(Err(Error::TooManyRequests))
));
let waiter = kio::Waiter::noop();
fetches.poll(&sub, start, &waiter);
assert_eq!(fetches.held.len(), 3, "one entry per fill");
assert!(callers.iter_mut().all(|caller| caller.now_or_never().is_none()));

let mut joined: Vec<_> = (1..=3)
.map(|sequence| track.consume().fetch_group(sequence, None))
.collect();
assert!(
dynamic.requested_fill().now_or_never().is_none(),
"joins existing fills"
);
drop(callers);
fetches.poll(&sub, start, &waiter);
assert_eq!(fetches.held.len(), 3, "the joined readers still own the demand");
assert!(joined.iter_mut().all(|caller| caller.now_or_never().is_none()));

drop(joined);
fetches.poll(&sub, start, &waiter);
assert!(fetches.held.is_empty(), "the last reader leaving releases every fill");
assert!(fetches.ready.read().is_empty());
assert_eq!(fetches.fold.deadline(), None);
assert!(dynamic.requested_fill().now_or_never().is_none());
}

#[moq_clock::test]
Expand Down Expand Up @@ -2607,37 +2624,6 @@ mod tests {
assert!(next.now_or_never().unwrap().is_ok());
}

/// A replacement takes the place of the attempt it replaces under the limit, before any
/// poll releases that one.
#[moq_clock::test]
async fn a_feed_fetch_replaces_an_abandoned_attempt_at_the_limit() {
let start = crate::time::Instant::now();
let clock = crate::time::Deadlines::new(start);
let tail = kio::Producer::new(Tail::default());
let sub = feed_sub(&tail).await;
let (track, mut callers, requests) = feed_batch([1, 2]);
let dynamic = track.requests();
let mut fetches = FeedFetches::new(&clock);
fetches.max = 2;
for req in requests {
fetches.push(req, &track.consume());
}
fetches.poll(&sub, start, &kio::Waiter::noop());
drop(callers.remove(0));
let mut next = track.consume().fetch_group(1, None);
let req = dynamic
.requested_fill()
.now_or_never()
.expect("replacement queued")
.unwrap();
fetches.push(req, &track.consume());
assert!((&mut next).now_or_never().is_none(), "held, not refused");
assert_eq!(fetches.held.len(), 2);
arrive(&track, &tail, 1, start);
fetches.poll(&sub, start, &kio::Waiter::noop());
assert!(next.now_or_never().unwrap().is_ok());
}

/// Sweep held fetches, unrelated tracks, and live arrival runs independently.
#[moq_clock::test]
#[ignore = "release benchmark, run by nightly"]
Expand Down Expand Up @@ -7681,15 +7667,18 @@ enum ServeMode {
/// A fill waits on one group at a time, the next it still owes. Each verdict on that group
/// also settles, by run, every group of the fill the feed gave up on, so a fill a peer
/// made wide costs what the cache and ledger hold rather than its width.
///
/// There is at most one held entry per model fill, shared by its readers. Network readers
/// own request streams (bounded by their downstream transport's credit); local readers
/// own their demand. The last reader leaving wakes `poll` to release the fill, so holding
/// it adds state proportional to existing demand, not another allowance on this upstream.
struct FeedFetches {
/// Each fill, by the group it waits on.
held: BTreeMap<u64, HeldFetch>,
ready: kio::Shared<BTreeSet<u64>>,
arrivals: Option<track::Arrivals>,
/// Only gaps containing a held group arm the earliest fold.
fold: crate::time::Deadline,
/// An additional track backstop, above one peer's default FETCH allowance.
max: usize,
#[cfg(test)]
polled: usize,
}
Expand Down Expand Up @@ -7722,7 +7711,6 @@ impl FeedFetches {
ready: Default::default(),
arrivals: None,
fold: crate::time::Deadline::new(clock),
max: crate::session::Limits::default().announces,
#[cfg(test)]
polled: 0,
}
Expand All @@ -7742,8 +7730,7 @@ impl FeedFetches {
self.hold(fill, true);
}

/// Wait on the next group `fill` still owes, if any. A fresh fill counts against the
/// limit, once what nobody waits on any more is released.
/// Wait on the next group `fill` still owes, if any.
fn hold(&mut self, fill: track::Fill, fresh: bool) {
let mut next = Some((fill, fresh));
while let Some((fill, fresh)) = next.take() {
Expand All @@ -7757,16 +7744,6 @@ impl FeedFetches {
{
next = Some((previous.fill, false));
}
if fresh {
let moving = usize::from(next.is_some());
if self.held.len() + moving >= self.max {
self.held.retain(|_, held| held.fill.wanted().is_some());
}
if self.held.len() + moving >= self.max {
fill.refuse(Error::TooManyRequests);
continue;
}
}
let waiter = kio::Waiter::new(std::task::Waker::from(Arc::new(FetchWake {
sequence,
ready: self.ready.clone(),
Expand Down
8 changes: 0 additions & 8 deletions rs/moq-net/src/model/track/fill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,14 +845,6 @@ impl Fill {
Poll::Ready(wanted)
}

/// Refuse every group still owed with `err`, which says nothing about whether the source
/// has them, so nothing is recorded dropped.
#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))]
pub(crate) fn refuse(&self, err: Error) {
let unresolved = self.inner.unresolved(self.inner.start.group..self.inner.end);
self.inner.refuse(&unresolved, err, self.max_delay());
}

/// The next run of groups still owed, in the fill's order: [`Self::wanted`]'s group,
/// extended over the owed groups beside it up to the nearest one the cache holds, so a
/// session asks its source for the whole run at once.
Expand Down