Skip to content

Commit 0effb82

Browse files
committed
Add locking
1 parent f290028 commit 0effb82

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

join/join.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func clusterExistingHeuristic(
100100

101101
wg := sync.WaitGroup{}
102102
wg.Add(len(nodes))
103+
lock := sync.Mutex{}
103104
activeNodes := make([]node.DiscoveryNode, 0, len(nodes))
104105
for _, n := range nodes {
105106
go func(n node.DiscoveryNode) {
@@ -116,6 +117,8 @@ func clusterExistingHeuristic(
116117
return
117118
}
118119
glog.Infof("Node %s looks alive and active in a cluster", n.NamedPeerURLs())
120+
lock.Lock()
121+
defer lock.Unlock()
119122
activeNodes = append(activeNodes, n)
120123
}(n)
121124
}

0 commit comments

Comments
 (0)