fix: harden accesspoint connection lifecycle#302
Merged
devgianlu merged 1 commit intodevgianlu:masterfrom Apr 12, 2026
Merged
Conversation
Prevent panics and races during AP close/reconnect by: - Initializing stop channels in the constructor instead of on each connect - Adding a permanent closed state that rejects Send/Receive/Connect after Close - Using non-blocking signal sends to avoid goroutine leaks - Protecting conn access with proper locking (closeConn, isStopped helpers) - Resetting pong-ack deadline on reconnect to avoid false timeouts
This was referenced Apr 6, 2026
Contributor
Author
|
The failing test is, as far as I can tell, not related to these changes. Seems to be a flakiness problem, so I opened a separate PR for that: #304 |
devgianlu
approved these changes
Apr 12, 2026
Owner
devgianlu
left a comment
There was a problem hiding this comment.
Thank you for the hardening work. I think at some point there should a "reconnatable conn" abstraction to be reused between the AP and the Dealer since they share a bunch of logic.
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.
I was seeing nil-pointer crashes and AP lifecycle issues in cliamp, and traced them to the access point close/reconnect flow being unsafe around early shutdown and concurrent I/O. In particular, the stop channels were only initialized inside
connect(), so closing early could not reliably stop AP goroutines, andpongAckTickercould panic when it tried to close a nil connection.Prevent panics and races during AP close/reconnect by:
Send/Connectand makesReceivereturn a closed channel afterCloseI also found some similar behavior in dealer and mercury, but opening those as separate PRs (as per the contribution guidelines :))