From 83989a19be58a49c609ade9e9d996cf78853e21d Mon Sep 17 00:00:00 2001 From: ucwong Date: Fri, 16 Sep 2022 17:33:48 +0800 Subject: [PATCH] core/rawdb: fix leak of backoff timer (#25776) --- core/rawdb/chain_freezer.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/rawdb/chain_freezer.go b/core/rawdb/chain_freezer.go index 7d9c9c0156..212ec73ed7 100644 --- a/core/rawdb/chain_freezer.go +++ b/core/rawdb/chain_freezer.go @@ -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: