Let the poll server restart after CleanupSRT - #84
Merged
Conversation
Regression from the shutdown support added alongside CI. The poll server was
created behind a sync.Once, so once CleanupSRT had stopped it and released
its epoll, it could never be replaced. The next non-blocking socket then
tried to register against the released epoll:
panic: ERROR ADDING FD TO EPOLL
pollserver.go:82 -> poll.go:109 -> srtgo.go:122
So InitSRT -> sockets -> CleanupSRT -> InitSRT -> socket, which worked at
9576f32, panicked afterwards. Start/stop/start is a reasonable thing for a
consumer to do, and nothing in the suite covered it.
Replace the sync.Once with a nil-checked, mutex-guarded pointer: shutdown
clears it, and the next socket constructs a fresh poll server with a fresh
epoll. Shutdown itself stays idempotent.
Adds the missing regression test, which panics without this change.
Verified: restart test passes; full suite under -race stays clean, 10/10 on
macOS arm64 and 10/10 on Linux amd64 with no segfaults, so the exit-teardown
fix is unaffected.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.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.
Fixes a regression I introduced in the previous commit, caught by testing a start/stop/start cycle that nothing in the suite covered.
The bug
CleanupSRTstops the poll server and releases its epoll. But the poll server was created behind async.Once, so it could never be replaced. The next non-blocking socket tried to register against the released epoll:This sequence worked at
9576f32and panicked after:Start/stop/start is a reasonable thing for a consumer to do — and the whole point of
CleanupSRTbeing exported.The fix
Replace the
sync.Oncewith a nil-checked, mutex-guarded pointer.pollServerShutdownclears it; the next socket constructs a fresh poll server with a fresh epoll.shutdown()itself stays idempotent via its ownstopOnce.Verification
TestPollServerRestartsAfterCleanuppanics without this change and passes with it.-race, no segfaults, 10/10 on macOS arm64 and 10/10 on Linux amd64.CI did not catch this because no test exercised a restart. That gap is now closed.
🤖 Generated with Claude Code