Skip to content
Snippets Groups Projects
Commit 03ee6022 authored by Patrick Hemmer's avatar Patrick Hemmer Committed by Daniel Nelson
Browse files

fix race in testutil Accumulator.Wait() (#2598)

parent cc5b2f68
No related branches found
No related tags found
No related merge requests found
......@@ -43,9 +43,9 @@ func (a *Accumulator) NMetrics() uint64 {
}
func (a *Accumulator) ClearMetrics() {
atomic.StoreUint64(&a.nMetrics, 0)
a.Lock()
defer a.Unlock()
atomic.StoreUint64(&a.nMetrics, 0)
a.Metrics = make([]*Metric, 0)
}
......@@ -56,9 +56,9 @@ func (a *Accumulator) AddFields(
tags map[string]string,
timestamp ...time.Time,
) {
atomic.AddUint64(&a.nMetrics, 1)
a.Lock()
defer a.Unlock()
atomic.AddUint64(&a.nMetrics, 1)
if a.Cond != nil {
a.Cond.Broadcast()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment