Skip to content

Ensure closed connections evict from ranking - #191

Merged
TimEvens merged 1 commit into
mainfrom
connection-close-ranking-removal
Sep 8, 2026
Merged

TimEvens merged 1 commit into
mainfrom
connection-close-ranking-removal

Conversation

@RichLogan

Copy link
Copy Markdown
Contributor

I think it's possible in a non-graceful PUBLISH_DONE case for tracks to linger in the ranking rather than be immediately removed. Here I remove any cleaned up publish subscribes from the ranking - although outside the lock because of the handler update callback removal takes.

@RichLogan
RichLogan requested a review from TimEvens September 4, 2026 14:38

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 708fe929df

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/client_manager.cc
Comment on lines +156 to +159
// Remove from top-n if no other connection publishes this track.
const auto next = state_.pub_subscribes.lower_bound({ remove_key.first, 0 });
if (next == state_.pub_subscribes.end() || next->first.first != remove_key.first) {
top_n_removal.emplace_back(std::move(handler));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Evict rankings owned by the disconnected publisher

When multiple connections publish the same track, the presence of another pub_subscribes entry does not mean the existing ranking entry is valid: TrackRanking stores only the connection ID and property value from the publisher that most recently updated that alias. If that publisher is the connection being purged, this condition skips removal and leaves its value and closed connection ID in the top-N until another publisher updates the property or the entry ages out, producing stale rankings and incorrect self-track filtering. Remove the disconnected handler's ranking entry or replace it with state from a surviving publisher rather than merely checking for the same track hash.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably matters but I'm not sure how much attention we should pay to multi-publisher ranking right now.

@TimEvens TimEvens left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TimEvens
TimEvens merged commit 56547f5 into main Sep 8, 2026
2 checks passed
@TimEvens
TimEvens deleted the connection-close-ranking-removal branch September 8, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants