fix data race
This commit is contained in:
parent
7888d3e13d
commit
652b1067f5
@ -70,21 +70,30 @@ func addNodes(old, neu []*registry.Node) []*registry.Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func addServices(old, neu []*registry.Service) []*registry.Service {
|
func addServices(old, neu []*registry.Service) []*registry.Service {
|
||||||
|
var srv []*registry.Service
|
||||||
|
|
||||||
for _, s := range neu {
|
for _, s := range neu {
|
||||||
var seen bool
|
var seen bool
|
||||||
for i, o := range old {
|
for _, o := range old {
|
||||||
if o.Version == s.Version {
|
if o.Version == s.Version {
|
||||||
s.Nodes = addNodes(o.Nodes, s.Nodes)
|
var sp *registry.Service
|
||||||
|
// make copy
|
||||||
|
*sp = *o
|
||||||
|
// set nodes
|
||||||
|
sp.Nodes = addNodes(o.Nodes, s.Nodes)
|
||||||
|
|
||||||
|
// mark as seen
|
||||||
seen = true
|
seen = true
|
||||||
old[i] = s
|
srv = append(srv, sp)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !seen {
|
if !seen {
|
||||||
old = append(old, s)
|
srv = append(srv, cp([]*registry.Service{s})...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return old
|
|
||||||
|
return srv
|
||||||
}
|
}
|
||||||
|
|
||||||
func delNodes(old, del []*registry.Node) []*registry.Node {
|
func delNodes(old, del []*registry.Node) []*registry.Node {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user