fix(moq-hls): release retired renditions instead of force-closing them#2394
Merged
Conversation
`renditions::Producer::clear` (called from `Broadcaster::drop`) closed every rendition's segment timeline before dropping it. That races the rendition's own watcher, which ends a cleanly-finished timeline with `end()` *then* `close()` -- and `end()` is what promotes the live-edge record into the final segment. Since `end()` is a no-op on an already-closed channel, a `close()` that lands first strands that record forever: the last segment of a recording is silently dropped. moq.pro's recorder hits exactly this shape, dropping the broadcaster right before it finalizes its uploads. Dropping the renditions instead is enough for what `clear` is actually for. A rendition nobody else holds drops here and its `Drop` aborts its watcher, so the map can no longer pin a standing timeline subscription after the broadcaster is gone. A rendition a cursor still holds is left to finish on its own, keeping its final segment, and still reaches a terminal state once its source ends. Retiring a rendition the CATALOG dropped keeps the force-close (added with the cursors): there the media continues into a replacement, so the live edge is genuinely incomplete and there is no `end()` to preserve -- only a cursor that would otherwise park forever. Also documents why `renditions::Producer::close` deliberately doesn't cascade into the segment channels: on a clean end it would race the same `end()`, and on a catalog-stream error it would truncate recordings whose media tracks are fine. Tests: the ordering hazard is pinned directly (`end()` after `close()` never finalizes the live edge), plus a broadcaster-drop test asserting a cursor still drains its final segment and then terminates. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Sorry @kixelated, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Co-Authored-By: OpenAI Codex <codex@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
end(), leaving the live edge unfinalized and silently dropping the recording's last segment.Rendition::closedocumentation to describe its catalog-removal lifecycle.Public API changes
None. The changed producer lifecycle is crate-private, and the existing recording API is unchanged.
Test plan
nix develop --command just fixnix develop --command just ciNo cross-package synchronization is required because this only changes internal
moq-hlsteardown behavior.(Written by Opus 4.8 and GPT-5)