-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix: exit ticktock goroutine when pool is closed #264
Conversation
@@ -116,10 +116,25 @@ func (p *Pool) ticktock() { | |||
defer ticker.Stop() | |||
|
|||
for range ticker.C { | |||
if p.IsClosed() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the better way to do this is to use context and select
in for
loop, like purgeStaleWorkers()
does.
So you should pass the context to ticktock()
and use an atomic int32 to indicate whether ticktock()
is done, handle these properly in ReleaseTimeout()
and Reboot()
.
In short, just do what exactly purgeStaleWorkers()
has already done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed, but I'm still concerned if atomic int32 is helpful for ticktock case since there is no worker-related awaiting logic. lmk if you need anything else
7e19d12
to
42086fe
Compare
Codecov ReportBase: 92.88% // Head: 93.17% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #264 +/- ##
==========================================
+ Coverage 92.88% 93.17% +0.28%
==========================================
Files 9 9
Lines 759 791 +32
==========================================
+ Hits 705 737 +32
Misses 41 41
Partials 13 13
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
name: Pull request
about: Fixes a bug
title: 'fix ticktock memory leaks'
labels: ''
assignees: ''
1. Are you opening this pull request for bug-fixs, optimizations or new feature?
bugfix
2. Please describe how these code changes achieve your intention.
The fix enables ticktock goroutine to stop it's execution.
3. Please link to the relevant issues (if any).
#263
4. Which documentation changes (if any) need to be made/updated because of this PR?
4. Checklist