mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 22:25:24 +01:00
multi: make sure missionControlStore
catches done
signal
This commit makes sure `missionControlStore` catches the shutdown signal when draining the ticker. A few debug logs are added to aid the process.
This commit is contained in:
parent
50279464ad
commit
2608c0893e
6 changed files with 25 additions and 10 deletions
|
@ -750,8 +750,8 @@ func (d *AuthenticatedGossiper) Stop() error {
|
|||
}
|
||||
|
||||
func (d *AuthenticatedGossiper) stop() {
|
||||
log.Info("Authenticated Gossiper is stopping")
|
||||
defer log.Info("Authenticated Gossiper stopped")
|
||||
log.Debug("Authenticated Gossiper is stopping")
|
||||
defer log.Debug("Authenticated Gossiper stopped")
|
||||
|
||||
d.blockEpochs.Cancel()
|
||||
|
||||
|
|
|
@ -149,6 +149,9 @@ func (d *DecayedLog) initBuckets() error {
|
|||
|
||||
// Stop halts the garbage collector and closes boltdb.
|
||||
func (d *DecayedLog) Stop() error {
|
||||
log.Debugf("DecayedLog shutting down...")
|
||||
defer log.Debugf("DecayedLog shutdown complete")
|
||||
|
||||
if !atomic.CompareAndSwapInt32(&d.stopped, 0, 1) {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -125,6 +125,9 @@ func (b *BitcoindFilteredChainView) Start() error {
|
|||
//
|
||||
// NOTE: This is part of the FilteredChainView interface.
|
||||
func (b *BitcoindFilteredChainView) Stop() error {
|
||||
log.Debug("BitcoindFilteredChainView stopping")
|
||||
defer log.Debug("BitcoindFilteredChainView stopped")
|
||||
|
||||
// Already shutting down?
|
||||
if atomic.AddInt32(&b.stopped, 1) != 1 {
|
||||
return nil
|
||||
|
@ -136,8 +139,6 @@ func (b *BitcoindFilteredChainView) Stop() error {
|
|||
|
||||
b.blockQueue.Stop()
|
||||
|
||||
log.Infof("FilteredChainView stopping")
|
||||
|
||||
close(b.quit)
|
||||
b.wg.Wait()
|
||||
|
||||
|
|
|
@ -135,6 +135,9 @@ func (b *BtcdFilteredChainView) Start() error {
|
|||
//
|
||||
// NOTE: This is part of the FilteredChainView interface.
|
||||
func (b *BtcdFilteredChainView) Stop() error {
|
||||
log.Debug("BtcdFilteredChainView stopping")
|
||||
defer log.Debug("BtcdFilteredChainView stopped")
|
||||
|
||||
// Already shutting down?
|
||||
if atomic.AddInt32(&b.stopped, 1) != 1 {
|
||||
return nil
|
||||
|
@ -146,8 +149,6 @@ func (b *BtcdFilteredChainView) Stop() error {
|
|||
|
||||
b.blockQueue.Stop()
|
||||
|
||||
log.Infof("FilteredChainView stopping")
|
||||
|
||||
close(b.quit)
|
||||
b.wg.Wait()
|
||||
|
||||
|
|
|
@ -135,13 +135,14 @@ func (c *CfFilteredChainView) Start() error {
|
|||
//
|
||||
// NOTE: This is part of the FilteredChainView interface.
|
||||
func (c *CfFilteredChainView) Stop() error {
|
||||
log.Debug("CfFilteredChainView stopping")
|
||||
defer log.Debug("CfFilteredChainView stopped")
|
||||
|
||||
// Already shutting down?
|
||||
if atomic.AddInt32(&c.stopped, 1) != 1 {
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Infof("FilteredChainView stopping")
|
||||
|
||||
close(c.quit)
|
||||
c.blockQueue.Stop()
|
||||
c.wg.Wait()
|
||||
|
|
|
@ -303,7 +303,11 @@ func (b *missionControlStore) run() {
|
|||
// channel needs to be drained appropriately. This could happen
|
||||
// if the flushInterval is very small (e.g. 1 nanosecond).
|
||||
if !timer.Stop() {
|
||||
<-timer.C
|
||||
select {
|
||||
case <-timer.C:
|
||||
case <-b.done:
|
||||
log.Debugf("Stopping mission control store")
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
|
@ -335,7 +339,12 @@ func (b *missionControlStore) run() {
|
|||
case <-b.done:
|
||||
// Release the timer's resources.
|
||||
if !timer.Stop() {
|
||||
<-timer.C
|
||||
select {
|
||||
case <-timer.C:
|
||||
case <-b.done:
|
||||
log.Debugf("Mission control " +
|
||||
"store stopped")
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue