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

Move cl.WriteLoop() to attachClient() and call cl.Stop() in loadClients() to update client.State. #344

Merged
merged 4 commits into from
Dec 22, 2023

Conversation

werbenhu
Copy link
Member

@werbenhu werbenhu commented Dec 13, 2023

In the server.loadClients() and when using inlineClient, NewClient() is called, but these may not necessarily represent actual connections. Calling go cl.WriteLoop() within NewClient() leads to a goroutine leak. I think moving go cl.WriteLoop() out of NewClient() and placing it in either server.EstablishConnection() or server.attachClient() would be more reasonable.

thedevop
thedevop previously approved these changes Dec 13, 2023
…n such as disconnected time, and set the stopCause.
@coveralls
Copy link

coveralls commented Dec 13, 2023

Pull Request Test Coverage Report for Build 7294678352

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 98.75%

Totals Coverage Status
Change from base Build 7294413132: 0.001%
Covered Lines: 5530
Relevant Lines: 5600

💛 - Coveralls

@werbenhu werbenhu requested review from mochi-co and x20080406 and removed request for dgduncan December 13, 2023 10:11
@werbenhu
Copy link
Member Author

@thedevop @x20080406 @mochi-co @dgduncan I have added a call to cl.Stop() in loadClients() to cancel the client's context, update cl.State with information such as disconnected time, and set the stopCause.

Please let me know if there are any other cases that need to be considered.

@werbenhu werbenhu changed the title Moving go cl.WriteLoop() out of NewClient() and placing it in attachClient() Call cl.WriteLoop() in attachClient() (not ready for merge). Dec 13, 2023
@werbenhu werbenhu changed the title Call cl.WriteLoop() in attachClient() (not ready for merge). Move cl.WriteLoop() to attachClient() and call cl.Stop() in loadClients() to update client.State. Dec 14, 2023
Copy link
Collaborator

@mochi-co mochi-co left a comment

Choose a reason for hiding this comment

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

This is a much better idea!

@mochi-co mochi-co merged commit b2ab984 into mochi-mqtt:main Dec 22, 2023
3 checks passed
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

5 participants