mirror of https://github.com/grpc/grpc-go.git
clustetresolver: Copy endpoints.Addresses slice from DNS updates to avoid data races (#7991)
This commit is contained in:
parent
f9bc335fc5
commit
aad8a12b45
|
|
@ -144,6 +144,9 @@ func buildClusterImplConfigForDNS(g *nameGenerator, endpoints []resolver.Endpoin
|
||||||
pName := fmt.Sprintf("priority-%v", g.prefix)
|
pName := fmt.Sprintf("priority-%v", g.prefix)
|
||||||
for i, e := range endpoints {
|
for i, e := range endpoints {
|
||||||
retEndpoints[i] = hierarchy.SetInEndpoint(e, []string{pName})
|
retEndpoints[i] = hierarchy.SetInEndpoint(e, []string{pName})
|
||||||
|
// Copy the nested address field as slice fields are shared by the
|
||||||
|
// iteration variable and the original slice.
|
||||||
|
retEndpoints[i].Addresses = append([]resolver.Address{}, e.Addresses...)
|
||||||
}
|
}
|
||||||
return pName, &clusterimpl.LBConfig{
|
return pName, &clusterimpl.LBConfig{
|
||||||
Cluster: mechanism.Cluster,
|
Cluster: mechanism.Cluster,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue