mirror of
https://github.com/status-im/consul.git
synced 2025-02-23 10:58:25 +00:00
bimapper: fix data race (#18519)
This commit is contained in:
parent
cc596ce772
commit
0b580ffd22
@ -272,7 +272,10 @@ func (m *Mapper) MapLink(_ context.Context, _ controller.Runtime, res *pbresourc
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mapper) itemIDsByLink(link resource.ReferenceKey) []*pbresource.ID {
|
func (m *Mapper) itemIDsByLink(link resource.ReferenceKey) []*pbresource.ID {
|
||||||
items, ok := m.getItemsByLink(link)
|
m.lock.Lock()
|
||||||
|
defer m.lock.Unlock()
|
||||||
|
|
||||||
|
items, ok := m.linkToItem[link]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -285,7 +288,10 @@ func (m *Mapper) itemIDsByLink(link resource.ReferenceKey) []*pbresource.ID {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mapper) itemRefsByLink(link resource.ReferenceKey) []*pbresource.Reference {
|
func (m *Mapper) itemRefsByLink(link resource.ReferenceKey) []*pbresource.Reference {
|
||||||
items, ok := m.getItemsByLink(link)
|
m.lock.Lock()
|
||||||
|
defer m.lock.Unlock()
|
||||||
|
|
||||||
|
items, ok := m.linkToItem[link]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -296,11 +302,3 @@ func (m *Mapper) itemRefsByLink(link resource.ReferenceKey) []*pbresource.Refere
|
|||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mapper) getItemsByLink(link resource.ReferenceKey) (map[resource.ReferenceKey]struct{}, bool) {
|
|
||||||
m.lock.Lock()
|
|
||||||
defer m.lock.Unlock()
|
|
||||||
|
|
||||||
items, ok := m.linkToItem[link]
|
|
||||||
return items, ok
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user