From 8e46c4649a900ac1c61c21786d883b04ac313038 Mon Sep 17 00:00:00 2001 From: ucwong Date: Fri, 3 Apr 2020 08:50:58 +0000 Subject: [PATCH] core : fix quit channel goroutine leak --- core/blockchain.go | 2 +- core/bloombits/matcher.go | 4 ++-- core/rawdb/freezer_reinit.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 0d1c27f95e..b316c2eb20 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -215,7 +215,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par db: db, triegc: prque.New(nil), stateCache: state.NewDatabaseWithCache(db, cacheConfig.TrieCleanLimit), - quit: make(chan struct{}), + quit: make(chan struct{}, 1), shouldPreserve: shouldPreserve, bodyCache: bodyCache, bodyRLPCache: bodyRLPCache, diff --git a/core/bloombits/matcher.go b/core/bloombits/matcher.go index 3ec0d5ae94..4dee49f6ce 100644 --- a/core/bloombits/matcher.go +++ b/core/bloombits/matcher.go @@ -154,8 +154,8 @@ func (m *Matcher) Start(ctx context.Context, begin, end uint64, results chan uin // Initiate a new matching round session := &MatcherSession{ matcher: m, - quit: make(chan struct{}), - kill: make(chan struct{}), + quit: make(chan struct{}, 1), + kill: make(chan struct{}, 1), ctx: ctx, } for _, scheduler := range m.schedulers { diff --git a/core/rawdb/freezer_reinit.go b/core/rawdb/freezer_reinit.go index d6bf9ab1dd..c11a59d9e0 100644 --- a/core/rawdb/freezer_reinit.go +++ b/core/rawdb/freezer_reinit.go @@ -44,7 +44,7 @@ func InitDatabaseFromFreezer(db ethdb.Database) error { number = ^uint64(0) // -1 results = make(chan *types.Block, 4*runtime.NumCPU()) ) - abort := make(chan struct{}) + abort := make(chan struct{}, 1) defer close(abort) for i := 0; i < runtime.NumCPU(); i++ {