From c69c2127fe74b4cafebda1d3a37ee3201f625e30 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 09:39:18 -0800 Subject: [PATCH] fix(net): a held or kept route stream resumes with what it missed A stream that is held or kept is sent no batches, so the claims it was last sent can fall behind its view. An edit that moves such a stream onto another route resumes it with no dirty region, and the incremental batch missed withdrawals made meanwhile. Holding or keeping a stream now clears its presented-from prefix, so its next batch diffs against all it holds, and the per-region patch for held streams goes. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/route/path.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/rs/moq-net/src/route/path.rs b/rs/moq-net/src/route/path.rs index 2707df16d36..395431f73ab 100644 --- a/rs/moq-net/src/route/path.rs +++ b/rs/moq-net/src/route/path.rs @@ -322,7 +322,8 @@ enum SentState { struct SentOffer { offer: Offer, /// The prefix of the view its claims were presented from, or `None` once an edit - /// rekeyed it: the next batch is diffed against all it holds. + /// rekeyed it or it was held or kept, missing batches: the next batch is diffed + /// against all it holds. from: Option, view: View, } @@ -350,6 +351,14 @@ impl Sent { }; self.state = SentState::Held(sent); } + self.behind(); + } + + /// It is sent nothing for now, so its next batch is diffed against all it holds. + fn behind(&mut self) { + if let SentState::Live(sent) | SentState::Held(sent) = &mut self.state { + sent.from = None; + } } fn end(&mut self) { @@ -2940,7 +2949,11 @@ impl Router { let sent = self.answering[&peer].tx.get(&key); let on = sent.is_some_and(|sent| sent.offer().is_some()); match want { - Want::Keep => {} + Want::Keep => { + if let Some(sent) = self.answering.get_mut(&peer).expect("answering").tx.get_mut(&key) { + sent.behind(); + } + } Want::Hold => { if on && !sent.expect("sent").held() { self.answering @@ -3072,16 +3085,7 @@ impl Router { let changes: Vec<(Path, Option)> = match (sent, dirty.all || fresh) { (Some(sent), false) => { let old = &sent.active().expect("offered").view; - let mut claims: BTreeSet<&Path> = dirty.claims.iter().collect(); - // A held stream may have missed withdrawals the local reader already - // consumed. When its region changes, include its own previous claims. - for region in &dirty.regions { - if let Some(region) = meet(prefix, region) { - claims.extend(below(&old.items, ®ion).map(|(claim, _)| claim)); - } - } - let mut changes: Vec<(&Path, Option<&A>)> = claims - .into_iter() + let mut changes: Vec<(&Path, Option<&A>)> = (dirty.claims.iter()) .filter(|claim| within(claim, prefix) && *claim != prefix) .map(|claim| (claim, view.items.get(claim))) .collect();