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

Close go routines when context is closed #786

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

AaronH88
Copy link
Contributor

@AaronH88 AaronH88 commented Jun 2, 2023

This PR addresses potential thread leaking in receptor.

@@ -356,6 +356,12 @@ func (s *Server) RunControlSvc(ctx context.Context, service string, tlscfg *tls.
if ctx.Err() != nil {
return
}
select {
case <-ctx.Done():
Copy link
Member

Choose a reason for hiding this comment

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

ctx.Err() is non-nil when context is closed. does that mean we are covered by the lines just above this select block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're correct, the logic will remain the same. Good spot

After looking at it some more I can see online that typically ctx.Err() is used when we want to return information on why the context was cancelled.
In this case, nothing is returned, so I'm wondering if I should replace the Err() with the Done(),
Any thoughts?

@AaronH88 AaronH88 force-pushed the close_contexts branch 3 times, most recently from 2d3c1ba to 0a0caba Compare June 8, 2023 11:36
@sonarcloud
Copy link

sonarcloud bot commented Jul 17, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

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.

3 participants