routing: move statTicker to prevent race condition

This commit is contained in:
nsa 2019-11-02 13:55:41 -04:00
parent 21a40daf58
commit b392dd1b95
No known key found for this signature in database
GPG Key ID: 118759E83439A9B1

@ -852,7 +852,6 @@ func (r *ChannelRouter) networkHandler() {
graphPruneTicker := time.NewTicker(r.cfg.GraphPruneInterval)
defer graphPruneTicker.Stop()
r.statTicker.Resume()
defer r.statTicker.Stop()
r.stats.Reset()
@ -862,6 +861,12 @@ func (r *ChannelRouter) networkHandler() {
validationBarrier := NewValidationBarrier(runtime.NumCPU()*4, r.quit)
for {
// If there are stats, resume the statTicker.
if !r.stats.Empty() {
r.statTicker.Resume()
}
select {
// A new fully validated network update has just arrived. As a
// result we'll modify the channel graph accordingly depending
@ -1344,8 +1349,6 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
return errors.Errorf("wrong routing update message type")
}
r.statTicker.Resume()
return nil
}