Skip to content

Commit 9f00816

Browse files
committed
fixed concurrent access to map
1 parent d39dade commit 9f00816

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

atlas/stream_strategy.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,19 @@ func (s *streamingStrategy) startListening(ctx context.Context, m config.Measure
6262
case <-ctx.Done():
6363
return
6464
case <-time.After(connectionRetryInterval):
65-
delete(s.measurements, m.ID)
65+
s.clearResults(m.ID)
6666
continue
6767
}
6868
}
6969
}
7070

71+
func (s *streamingStrategy) clearResults(id string) {
72+
s.mu.Lock()
73+
defer s.mu.Unlock()
74+
75+
delete(s.measurements, id)
76+
}
77+
7178
func (s *streamingStrategy) timeoutForMeasurement(m config.Measurement) time.Duration {
7279
if m.Timeout == 0 {
7380
return s.defaultTimeout

0 commit comments

Comments
 (0)