core/rawdb: fix leak of backoff timer (#25776)

This commit is contained in:
ucwong 2022-09-16 17:33:48 +08:00 committed by GitHub
parent 57a65f00c9
commit 83989a19be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -92,6 +92,8 @@ func (f *chainFreezer) freeze(db ethdb.KeyValueStore) {
backoff bool
triggered chan struct{} // Used in tests
)
timer := time.NewTimer(freezerRecheckInterval)
defer timer.Stop()
for {
select {
case <-f.quit:
@ -106,8 +108,9 @@ func (f *chainFreezer) freeze(db ethdb.KeyValueStore) {
triggered = nil
}
select {
case <-time.NewTimer(freezerRecheckInterval).C:
case <-timer.C:
backoff = false
timer.Reset(freezerRecheckInterval)
case triggered = <-f.trigger:
backoff = false
case <-f.quit: