From b392dd1b954a1dd9755785977c02f6682e56cf68 Mon Sep 17 00:00:00 2001 From: nsa Date: Sat, 2 Nov 2019 13:55:41 -0400 Subject: [PATCH] routing: move statTicker to prevent race condition --- routing/router.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/routing/router.go b/routing/router.go index 3908a93d..2a1fa296 100644 --- a/routing/router.go +++ b/routing/router.go @@ -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 }