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

fix(dialqueue): fix a timer leak #466

Merged
merged 1 commit into from
Feb 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dial_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ func (dq *dialQueue) worker() {
// This idle timer tracks if the environment is slow. If we're waiting to long to acquire a peer to dial,
// it means that the DHT query is progressing slow and we should shrink the worker pool.
idleTimer := time.NewTimer(24 * time.Hour) // placeholder init value which will be overridden immediately.
defer idleTimer.Stop()
for {
// trap exit signals first.
select {
Expand All @@ -308,6 +309,11 @@ func (dq *dialQueue) worker() {
select {
case <-idleTimer.C:
default:
// NOTE: There is a slight race here. We could be in the
// middle of firing the timer and not read anything from the channel.
//
// However, that's not really a huge issue. We'll think
// we're idle but that's fine.
}
idleTimer.Reset(dq.config.maxIdle)

Expand Down