Merge pull request #21433 from holiman/statsync_exiter

eth/downloader: allow all timers to exit
This commit is contained in:
Péter Szilágyi 2020-08-10 12:08:46 +03:00 committed by GitHub
commit cbbc54c495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -200,12 +200,7 @@ func (d *Downloader) runStateSync(s *stateSync) *stateSync {
} }
// Start a timer to notify the sync loop if the peer stalled. // Start a timer to notify the sync loop if the peer stalled.
req.timer = time.AfterFunc(req.timeout, func() { req.timer = time.AfterFunc(req.timeout, func() {
select { timeout <- req
case timeout <- req:
case <-s.done:
// Prevent leaking of timer goroutines in the unlikely case where a
// timer is fired just before exiting runStateSync.
}
}) })
active[req.peer.id] = req active[req.peer.id] = req
} }
@ -217,7 +212,6 @@ func (d *Downloader) runStateSync(s *stateSync) *stateSync {
// are marked as idle and de facto _are_ idle. // are marked as idle and de facto _are_ idle.
func (d *Downloader) spindownStateSync(active map[string]*stateReq, finished []*stateReq, timeout chan *stateReq, peerDrop chan *peerConnection) { func (d *Downloader) spindownStateSync(active map[string]*stateReq, finished []*stateReq, timeout chan *stateReq, peerDrop chan *peerConnection) {
log.Trace("State sync spinning down", "active", len(active), "finished", len(finished)) log.Trace("State sync spinning down", "active", len(active), "finished", len(finished))
for len(active) > 0 { for len(active) > 0 {
var ( var (
req *stateReq req *stateReq