routing: clean up locking on topology change
This commit is contained in:
parent
f289a39c1a
commit
4e0ada9ea3
@ -118,10 +118,9 @@ type topologyClient struct {
|
|||||||
// graph topology in a non-blocking.
|
// graph topology in a non-blocking.
|
||||||
func (r *ChannelRouter) notifyTopologyChange(topologyDiff *TopologyChange) {
|
func (r *ChannelRouter) notifyTopologyChange(topologyDiff *TopologyChange) {
|
||||||
r.RLock()
|
r.RLock()
|
||||||
numClients := len(r.topologyClients)
|
defer r.RUnlock()
|
||||||
r.RUnlock()
|
|
||||||
|
|
||||||
// Do not reacquire the lock twice unnecessarily.
|
numClients := len(r.topologyClients)
|
||||||
if numClients == 0 {
|
if numClients == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -133,7 +132,6 @@ func (r *ChannelRouter) notifyTopologyChange(topologyDiff *TopologyChange) {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
r.RLock()
|
|
||||||
for _, client := range r.topologyClients {
|
for _, client := range r.topologyClients {
|
||||||
client.wg.Add(1)
|
client.wg.Add(1)
|
||||||
|
|
||||||
@ -157,7 +155,6 @@ func (r *ChannelRouter) notifyTopologyChange(topologyDiff *TopologyChange) {
|
|||||||
}
|
}
|
||||||
}(client)
|
}(client)
|
||||||
}
|
}
|
||||||
r.RUnlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TopologyChange represents a new set of modifications to the channel graph.
|
// TopologyChange represents a new set of modifications to the channel graph.
|
||||||
|
Loading…
Reference in New Issue
Block a user