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

Fixed memory leak when authentication is wrong #178

Closed
wants to merge 7 commits into from

Conversation

xorduna
Copy link

@xorduna xorduna commented Oct 27, 2022

We had an mqtt client that was continously attempting to login with a wrong token into our broker and the memory usage was going up and up.

After digging into the problem, we found that after the connection was closed, two goroutines were still running: writeLoop() and serve(). serve() was blocked waiting for the closing of the client.wg.Wait(), and this wait group was still waiting for the writeLoop() to end. And the writeLoop() was blocked because it was waiting for the client.close channel. The defer in the serve() closed client.closed, but not client.close.

On this date, we still don't see the difference between client.closed and client.close, but closing client.close in case there is an error was necessary to end both go routines.

In any case, I am open to the discussion.

Thanks

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