Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Listener WG to track clients #301

Merged
merged 1 commit into from
Sep 22, 2023

Conversation

mochi-co
Copy link
Collaborator

@mochi-co mochi-co commented Sep 20, 2023

Following #298 and #299, this PR presents a small solution to track the connection alive status of every client by repurposing the Listeners waitgroup to track clients instead of listeners. This change ensures that the Hooks shutdown sequence cannot be completed until all clients have successfully and sequentially exited their goroutines (between cl.Read and OnDisconnect). In this way, we can leverage the existing shutdown signally code.

Tests are unaffected, Paho passing.

@werbenhu
Copy link
Member

@mochi-co This code is absolutely perfect and effective, and it is also incredibly simple and clean, which is exactly what we all expect in code. Thanks.

@mochi-co mochi-co merged commit fbb1fb2 into main Sep 22, 2023
6 checks passed
@mochi-co mochi-co deleted the wait-for-all-clients-to-disconnect-before-continuing branch September 22, 2023 18:47
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.

None yet

3 participants