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

eth/downloader : avoid timer leak #29596

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 13 additions & 6 deletions eth/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,11 +1015,16 @@ func (d *Downloader) fetchHeaders(p *peerConnection, from uint64, head uint64) e

// Start pulling the header chain skeleton until all is done
var (
skeleton = true // Skeleton assembly phase or finishing up
pivoting = false // Whether the next request is pivot verification
ancestor = from
mode = d.getMode()
skeleton = true // Skeleton assembly phase or finishing up
pivoting = false // Whether the next request is pivot verification
ancestor = from
mode = d.getMode()
headerCheckTimer = time.NewTimer(fsHeaderContCheck)
headerDelayedTimer = time.NewTimer(fsHeaderContCheck)
)
defer headerCheckTimer.Stop()
defer headerDelayedTimer.Stop()
jwasinger marked this conversation as resolved.
Show resolved Hide resolved

for {
// Pull the next batch of headers, it either:
// - Pivot check to see if the chain moved too far
Expand Down Expand Up @@ -1124,8 +1129,9 @@ func (d *Downloader) fetchHeaders(p *peerConnection, from uint64, head uint64) e
// Don't abort header fetches while the pivot is downloading
if !d.committed.Load() && pivot <= from {
p.log.Debug("No headers, waiting for pivot commit")
headerCheckTimer.Reset(fsHeaderContCheck)
select {
case <-time.After(fsHeaderContCheck):
case <-headerCheckTimer.C:
continue
case <-d.cancelCh:
return errCanceled
Expand Down Expand Up @@ -1195,8 +1201,9 @@ func (d *Downloader) fetchHeaders(p *peerConnection, from uint64, head uint64) e
// skeleton filling
if len(headers) == 0 && !progressed {
p.log.Trace("All headers delayed, waiting")
headerDelayedTimer.Reset(fsHeaderContCheck)
select {
case <-time.After(fsHeaderContCheck):
case <-headerDelayedTimer.C:
continue
case <-d.cancelCh:
return errCanceled
Expand Down