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
commit 863d795c94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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