Merge pull request #3616 from Crypt-iQ/router_race_1019

ticker: add tickerMtx to prevent data race
This commit is contained in:
Olaoluwa Osuntokun
2019-11-05 19:47:18 -08:00
committed by GitHub

View File

@@ -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
}