routing: do not reacquire the lock for topology notifications

This commit is contained in:
maurycy authored and Olaoluwa Osuntokun committed 2018-07-10 17:09:52 -07:00
1 parent 273f030390
commit 3915c6a569
1 file changed
+11 -7
+11 -7
View File
@@ -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)