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

prevents a goroutine from being leaked if a timeout occurs when calling forceCloseConnection #2854

Merged
merged 1 commit into from
May 17, 2021

Conversation

hex0punk
Copy link
Contributor

@hex0punk hex0punk commented Apr 27, 2021

Summary

Fixes potential edge case which could result in a goroutine leak, applies general best practice for working with channels.

A goroutine leak could occur in the following edge case scenario:

In the case that the case in https://github.com/aws/amazon-ecs-agent/blob/master/agent/wsclient/client.go#L274-L285 executes first, the function will return and the anonymous goroutine in https://github.com/aws/amazon-ecs-agent/blob/master/agent/wsclient/client.go#L269 would continue to be blocked, causing a goroutine leak. Using a buffered channel prevents this issue.

Implementation details

Made an unbuffered channel into a buffered channel

Testing

New tests cover the changes: no

Description for the changelog

bugfix - fix potential goroutine leak when closing websocket connections

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor

@sparrc sparrc left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

@sparrc sparrc merged commit 384129a into aws:dev May 17, 2021
@fenxiong fenxiong added this to the 1.52.2 milestone May 19, 2021
@fenxiong fenxiong mentioned this pull request May 19, 2021
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.

5 participants