routing: do not reacquire the lock for topology notifications

This commit is contained in:
maurycy 2018-06-21 08:43:37 +02:00 committed by Olaoluwa Osuntokun
parent 273f030390
commit 3915c6a569

@ -113,15 +113,19 @@ func (r *ChannelRouter) notifyTopologyChange(topologyDiff *TopologyChange) {
r.RLock()
numClients := len(r.topologyClients)
r.RUnlock()
if numClients != 0 {
log.Tracef("Sending topology notification to %v clients %v",
numClients,
newLogClosure(func() string {
return spew.Sdump(topologyDiff)
}),
)
// Do not reacquire the lock twice unnecessarily.
if numClients == 0 {
return
}
log.Tracef("Sending topology notification to %v clients %v",
numClients,
newLogClosure(func() string {
return spew.Sdump(topologyDiff)
}),
)
r.RLock()
for _, client := range r.topologyClients {
client.wg.Add(1)