Skip to content

Isolate listeners per server#145

Merged
mattn merged 1 commit into
masterfrom
fix/per-server-listeners
May 8, 2026
Merged

Isolate listeners per server#145
mattn merged 1 commit into
masterfrom
fix/per-server-listeners

Conversation

@mattn

@mattn mattn commented May 5, 2026

Copy link
Copy Markdown
Collaborator

Move the global listeners map and mutex onto Server so each Server instance manages its own subscriptions, eliminating cross-server interference; GetListeningFilters and BroadcastEvent now iterate registered servers.

Benefits:

  1. Servers no longer interfere with each other — multiple relays can coexist in one process without subscriptions leaking across them.
  2. Lock contention is reduced — each Server has its own mutex, improving concurrency.
  3. No state leaks — discarding a Server also discards its listeners.
  4. Tests are independent — without global state, parallel and sequential tests don't interfere.

@mattn mattn merged commit c49feb8 into master May 8, 2026
1 check passed
@mattn mattn deleted the fix/per-server-listeners branch May 8, 2026 15:02
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