Skip to content

Commit

Permalink
fix: topology all can cause race
Browse files Browse the repository at this point in the history
Topology.All() was incorrectly modifying the existing topology map
instead of copying it which can cause a race `fatal error: concurrent
map read and map write` under normal usage.

Signed-off-by: Michael Nairn <[email protected]>
  • Loading branch information
mikenairn committed Oct 24, 2024
1 parent 0cb371b commit 4983c5d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion machinery/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ func (t *Topology) Objects() *collection[Object] {

// All returns all object nodes in the topology.
func (t *Topology) All() *collection[Object] {
allObjects := t.objects
allObjects := map[string]Object{}
for k, v := range t.objects {
allObjects[k] = v
}
for k, v := range t.targetables {
allObjects[k] = v
}
Expand Down

0 comments on commit 4983c5d

Please sign in to comment.