diff --git a/rs/moq-net/src/route/path.rs b/rs/moq-net/src/route/path.rs index 41b2460f849..a262bb3605e 100644 --- a/rs/moq-net/src/route/path.rs +++ b/rs/moq-net/src/route/path.rs @@ -350,7 +350,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, } @@ -378,6 +379,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) { @@ -3006,7 +3015,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 @@ -3141,16 +3154,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)> = claims - .into_iter() + let mut changes: Vec<(&Path, Option)> = (dirty.claims.iter()) .filter(|claim| within(claim, prefix) && *claim != prefix) .map(|claim| (claim, view.items.get(claim).cloned())) .collect();