We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents db988a4 + acd2c4e commit cc6c584Copy full SHA for cc6c584
core/chain_manager.go
@@ -76,7 +76,8 @@ type ChainManager struct {
76
cache *lru.Cache // cache is the LRU caching
77
futureBlocks *lru.Cache // future blocks are blocks added for later processing
78
79
- quit chan struct{}
+ quit chan struct{}
80
+ running int32 // running must be called automically
81
// procInterrupt must be atomically called
82
procInterrupt int32 // interrupt signaler for block processing
83
wg sync.WaitGroup
@@ -451,6 +452,9 @@ func (bc *ChainManager) setTotalDifficulty(td *big.Int) {
451
452
}
453
454
func (bc *ChainManager) Stop() {
455
+ if !atomic.CompareAndSwapInt32(&bc.running, 0, 1) {
456
+ return
457
+ }
458
close(bc.quit)
459
atomic.StoreInt32(&bc.procInterrupt, 1)
460
0 commit comments