Skip to content

relay: fix shutdown hang when sessions hold lingering server refs#359

Merged
afrind merged 1 commit into
mainfrom
relay/io-executor-owned-by-main
May 31, 2026
Merged

relay: fix shutdown hang when sessions hold lingering server refs#359
afrind merged 1 commit into
mainfrom
relay/io-executor-owned-by-main

Conversation

@afrind
Copy link
Copy Markdown
Contributor

@afrind afrind commented May 31, 2026

main() now owns the IOThreadPoolExecutor via unique_ptr (servers hold a
raw pointer) and explicitly stops + clears servers before joining the IO
pool. Previously, lingering shared_ptr refs from in-flight
sessions or coroutines could delay ~MoqxRelayServer past the executor's
destruction, leaving QuicServer::shutdown to post to dead worker EVBs
and hang shutdown until the 10s watchdog fired.

MoqxRelayServer::stop() and MoqxPicoRelayServer::stop() are made
idempotent using context_ as the sentinel, so ~MoqxRelayServer is a
no-op once main has already stopped the server.


This change is Reviewable

main() now owns the IOThreadPoolExecutor via unique_ptr (servers hold a
raw pointer) and explicitly stops + clears servers before joining the IO
pool. Previously, lingering shared_ptr<MoQServerBase> refs from in-flight
sessions or coroutines could delay ~MoqxRelayServer past the executor's
destruction, leaving QuicServer::shutdown to post to dead worker EVBs
and hang shutdown until the 10s watchdog fired.

MoqxRelayServer::stop() and MoqxPicoRelayServer::stop() are made
idempotent using context_ as the sentinel, so ~MoqxRelayServer is a
no-op once main has already stopped the server.
@afrind afrind force-pushed the relay/io-executor-owned-by-main branch from 01d7417 to fef5413 Compare May 31, 2026 21:58
@afrind afrind changed the title relay: IOThreadPoolExecutor owned exclusively by main relay: fix shutdown hang when sessions hold lingering server refs May 31, 2026
Copy link
Copy Markdown
Contributor

@gmarzot gmarzot left a comment

Choose a reason for hiding this comment

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

@gmarzot reviewed 5 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on akash-a-n, michalhosna, mondain, Oxyd, peterchave, suhasHere, and TimEvens).

@afrind afrind merged commit f1d4f5c into main May 31, 2026
16 checks passed
@afrind afrind deleted the relay/io-executor-owned-by-main branch May 31, 2026 22:08
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