Skip to content

Commit 2608c08

Browse files
committed
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.
1 parent 5027946 commit 2608c08

File tree

6 files changed

+25
-10
lines changed

6 files changed

+25
-10
lines changed

discovery/gossiper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,8 @@ func (d *AuthenticatedGossiper) Stop() error {
750750
}
751751

752752
func (d *AuthenticatedGossiper) stop() {
753-
log.Info("Authenticated Gossiper is stopping")
754-
defer log.Info("Authenticated Gossiper stopped")
753+
log.Debug("Authenticated Gossiper is stopping")
754+
defer log.Debug("Authenticated Gossiper stopped")
755755

756756
d.blockEpochs.Cancel()
757757

htlcswitch/decayedlog.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ func (d *DecayedLog) initBuckets() error {
149149

150150
// Stop halts the garbage collector and closes boltdb.
151151
func (d *DecayedLog) Stop() error {
152+
log.Debugf("DecayedLog shutting down...")
153+
defer log.Debugf("DecayedLog shutdown complete")
154+
152155
if !atomic.CompareAndSwapInt32(&d.stopped, 0, 1) {
153156
return nil
154157
}

routing/chainview/bitcoind.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ func (b *BitcoindFilteredChainView) Start() error {
125125
//
126126
// NOTE: This is part of the FilteredChainView interface.
127127
func (b *BitcoindFilteredChainView) Stop() error {
128+
log.Debug("BitcoindFilteredChainView stopping")
129+
defer log.Debug("BitcoindFilteredChainView stopped")
130+
128131
// Already shutting down?
129132
if atomic.AddInt32(&b.stopped, 1) != 1 {
130133
return nil
@@ -136,8 +139,6 @@ func (b *BitcoindFilteredChainView) Stop() error {
136139

137140
b.blockQueue.Stop()
138141

139-
log.Infof("FilteredChainView stopping")
140-
141142
close(b.quit)
142143
b.wg.Wait()
143144

routing/chainview/btcd.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ func (b *BtcdFilteredChainView) Start() error {
135135
//
136136
// NOTE: This is part of the FilteredChainView interface.
137137
func (b *BtcdFilteredChainView) Stop() error {
138+
log.Debug("BtcdFilteredChainView stopping")
139+
defer log.Debug("BtcdFilteredChainView stopped")
140+
138141
// Already shutting down?
139142
if atomic.AddInt32(&b.stopped, 1) != 1 {
140143
return nil
@@ -146,8 +149,6 @@ func (b *BtcdFilteredChainView) Stop() error {
146149

147150
b.blockQueue.Stop()
148151

149-
log.Infof("FilteredChainView stopping")
150-
151152
close(b.quit)
152153
b.wg.Wait()
153154

routing/chainview/neutrino.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,14 @@ func (c *CfFilteredChainView) Start() error {
135135
//
136136
// NOTE: This is part of the FilteredChainView interface.
137137
func (c *CfFilteredChainView) Stop() error {
138+
log.Debug("CfFilteredChainView stopping")
139+
defer log.Debug("CfFilteredChainView stopped")
140+
138141
// Already shutting down?
139142
if atomic.AddInt32(&c.stopped, 1) != 1 {
140143
return nil
141144
}
142145

143-
log.Infof("FilteredChainView stopping")
144-
145146
close(c.quit)
146147
c.blockQueue.Stop()
147148
c.wg.Wait()

routing/missioncontrol_store.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ func (b *missionControlStore) run() {
303303
// channel needs to be drained appropriately. This could happen
304304
// if the flushInterval is very small (e.g. 1 nanosecond).
305305
if !timer.Stop() {
306-
<-timer.C
306+
select {
307+
case <-timer.C:
308+
case <-b.done:
309+
log.Debugf("Stopping mission control store")
310+
}
307311
}
308312

309313
for {
@@ -335,7 +339,12 @@ func (b *missionControlStore) run() {
335339
case <-b.done:
336340
// Release the timer's resources.
337341
if !timer.Stop() {
338-
<-timer.C
342+
select {
343+
case <-timer.C:
344+
case <-b.done:
345+
log.Debugf("Mission control " +
346+
"store stopped")
347+
}
339348
}
340349
return
341350
}

0 commit comments

Comments
 (0)