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
32 changes: 0 additions & 32 deletions quest/m0/test-flakes-3/py-socket-abort.md

This file was deleted.

2 changes: 0 additions & 2 deletions quest/m2/sockets/remove.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ For the PR:
must already be off it.
- Record the PR's parent commit in the PR body: it is the reference Kixel
ports from.
- If [the closed-endpoint flake](/quest/m0/test-flakes-3/py-socket-abort.md)
is still open, delete it here: its test leaves.
- Run `just test interop --all` (moq-ffi changes) and `just api-diff`.

Public API: breaking for `main`-only API in every language; nothing on
Expand Down
88 changes: 82 additions & 6 deletions rs/moq-net/src/model/front.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ struct Track {
/// The most recent refusal, reported when every source has refused, with the Retry
/// Interval an upstream refusal asked for.
refusal: Option<(Error, Option<Duration>)>,
/// Why the serving copy died mid-serve, while its re-splice is asked for. A refusal of
/// that re-splice reports this instead: the source closing is what ended the track.
/// Why the serving copy died mid-serve, or what a closing source answered, while a
/// re-splice is awaited. A refusal of that re-splice, or the front ending first, reports
/// this instead: the source closing is what ended the track.
lost: Option<Error>,
/// Whether anyone reads the track: a copy is only spliced in for a reader.
wanted: bool,
Expand Down Expand Up @@ -276,8 +277,8 @@ impl Front {
self.serving.map(|(source, _)| source)
}

/// Why `track`'s serving copy died mid-serve, while its re-splice is still asked for.
/// A track the front ends meanwhile ends with this rather than the front's end.
/// Why `track`'s serving copy died, while its re-splice is still awaited. A track the
/// front ends meanwhile ends with this rather than the front's end.
pub(super) fn lost(&self, track: &str) -> Option<Error> {
self.tracks.get(track)?.lost.clone()
}
Expand Down Expand Up @@ -644,9 +645,11 @@ impl Front {
let serving = self.serving.is_some_and(|(serving, _)| serving == source);
let track = self.tracks.get_mut(&name).expect("refusing a known track");
track.state = TrackState::Idle;
// A closing source's answer is not a verdict: it is on its way out and
// its replacement is asked afresh.
// A closing source's answer is not a verdict: it is on its way out and its
// replacement is asked afresh. It is still what ended the track if nothing replaces
// the source, unless an earlier loss did.
if closing {
track.lost.get_or_insert(refusal.0);
return;
}
// A route that lost the content says nothing of the track: wait for another of its
Expand Down Expand Up @@ -1258,6 +1261,79 @@ mod tests {
);
}

/// A copy reset before delivering, seen only once its source began closing, such as a
/// session of a closing socket endpoint, is no refusal, yet ends the track with the reset
/// rather than `Unroutable` when nothing replaces the source, or when its replacement
/// refuses. The driver reports it as the copy's end once spliced, or as the answer to
/// its query when the reset came before the metadata was read.
#[test]
fn a_closing_source_reset_reports_the_loss() {
let reset = || Error::from(crate::StreamError::Session(crate::SessionError::Cancel));
let ended = || {
let mut front = serving(local(1), 100);
let actions = front.step(Event::TrackEnded {
track: name("video"),
source: 100,
closing: true,
result: Err(reset()),
delivered: false,
});
(front, actions)
};
let answered = || {
let mut front = querying(local(1), 100);
let actions = front.step(Event::TrackInfo {
track: name("video"),
source: 100,
closing: true,
result: Err(reset()),
retry: None,
});
(front, actions)
};
for (mut front, actions) in [ended(), answered()] {
assert_actions(actions, &[]);
assert!(front.tracks[&name("video")].refused.is_empty());
front.step(Event::SourceClosed { source: 100 });

let mut replaced = front.clone();
replaced.step(Event::Selected {
best: Some(local(2)),
serving_closing: false,
});
replaced.step(Event::Resolved {
route: 2,
result: Ok(200),
});
assert_actions(
replaced.step(Event::TrackInfo {
track: name("video"),
source: 200,
closing: false,
result: Err(Error::NotFound),
retry: None,
}),
&[Action::Abort {
track: name("video"),
err: reset(),
retry: None,
}],
);

assert_actions(
front.step(Event::Selected {
best: None,
serving_closing: false,
}),
&[Action::End { err: Error::Unroutable }],
);
assert_eq!(
front.lost("video").map(|err| err.to_string()),
Some(reset().to_string())
);
}
}

/// A source that loses a copy mid-serve and then refuses its re-splice, such as a
/// closing socket endpoint, ends the track with the loss, not the refusal.
#[test]
Expand Down