Skip to content

MoQForwarder: add passive channel subscribers that don't gate forwarding#249

Open
afrind wants to merge 2 commits into
mainfrom
pr185
Open

MoQForwarder: add passive channel subscribers that don't gate forwarding#249
afrind wants to merge 2 commits into
mainfrom
pr185

Conversation

@afrind
Copy link
Copy Markdown
Collaborator

@afrind afrind commented Jun 1, 2026

Adds a passive flag to addChannelSubscriber() for the relay's own
internal observer chain (top-N / termination / cache) attached below a
local-forwarder primary. Passive subscribers are not real downstream
consumers, so they must not influence the forwarder's "are there active
consumers" accounting:

  • They increment passiveCount_ instead of calling addForwardingSubscriber(),
    so they don't count toward forwardingSubscribers_ or block onEmpty. The
    primary's onEmpty still fires once the last real cross-exec subscriber
    leaves.
  • In beginSubgroup(), resetting a passive subscriber's stale subgroup no
    longer sets anyReset. Passive subscribers never stop_sending, so counting
    them would mask the "no active consumers" signal and prevent a duplicate
    subgroup from propagating CANCELLED back to the publisher after all real
    consumers have stop_sent.

This change is Reviewable

afrind and others added 2 commits May 31, 2026 22:55
kAutoRequestID is a sentinel RequestID (max uint64) that callers can pass
in a JoiningFetch to let the session find the matching subscribe by track
name rather than requiring the caller to track the request ID manually.

resolveJoiningFetch handles both the auto case (searches pendingRequests_
and subTracks_ by FullTrackName, writes back the resolved ID) and the
explicit case (existing lookup + validation), replacing the inline block
in MoQSession::fetch with a single call.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary:
Adds a `passive` flag to addChannelSubscriber() for the relay's own
internal observer chain (top-N / termination / cache) attached below a
local-forwarder primary. Passive subscribers are not real downstream
consumers, so they must not influence the forwarder's "are there active
consumers" accounting:

- They increment passiveCount_ instead of calling addForwardingSubscriber(),
  so they don't count toward forwardingSubscribers_ or block onEmpty. The
  primary's onEmpty still fires once the last real cross-exec subscriber
  leaves.
- In beginSubgroup(), resetting a passive subscriber's stale subgroup no
  longer sets anyReset. Passive subscribers never stop_sending, so counting
  them would mask the "no active consumers" signal and prevent a duplicate
  subgroup from propagating CANCELLED back to the publisher after all real
  consumers have stop_sent.

Test Plan:
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.

1 participant