core : fix quit channel goroutine leak

This commit is contained in:
ucwong 2020-04-03 08:50:58 +00:00
parent f7b29ec942
commit 8e46c4649a
3 changed files with 4 additions and 4 deletions

View file

@ -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,

View file

@ -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 {

View file

@ -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++ {