Skip to content

Commit 338389f

Browse files
authored
[receiver/discovery] Fix attributes locking mechanism (#4712)
Otherwise both lock and unlock are deffered
1 parent acfb907 commit 338389f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/receiver/discoveryreceiver/correlation.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ func (s *store) GetOrCreate(receiverID component.ID, endpointID observer.Endpoin
154154
}
155155

156156
func (s *store) Attrs(receiverID component.ID) map[string]string {
157-
defer s.receiverLocks.Lock(receiverID)()
157+
unlock := s.receiverLocks.Lock(receiverID)
158+
defer unlock()
158159
rInfo, _ := s.receiverAttrs.LoadOrStore(receiverID, map[string]string{})
159160
receiverInfo := rInfo.(map[string]string)
160161
cp := map[string]string{}
@@ -165,7 +166,8 @@ func (s *store) Attrs(receiverID component.ID) map[string]string {
165166
}
166167

167168
func (s *store) UpdateAttrs(receiverID component.ID, attrs map[string]string) {
168-
defer s.receiverLocks.Lock(receiverID)()
169+
unlock := s.receiverLocks.Lock(receiverID)
170+
defer unlock()
169171
rAttrs, _ := s.receiverAttrs.LoadOrStore(receiverID, map[string]string{})
170172
receiverAttrs := rAttrs.(map[string]string)
171173
for k, v := range attrs {

0 commit comments

Comments
 (0)