From 6dab912b12b43e94c2d62a8e623b675d59f7abc7 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Wed, 28 Apr 2021 16:16:28 -0400 Subject: [PATCH] inmem: create a new RWMutex, because they are not safe to copy --- inmem.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inmem.go b/inmem.go index e8206da..71deef1 100644 --- a/inmem.go +++ b/inmem.go @@ -245,6 +245,8 @@ func (i *InmemSink) Data() []*IntervalMetrics { copyCurrent := intervals[n-1] current.RLock() *copyCurrent = *current + // RWMutex is not safe to copy, so create a new instance on the copy + copyCurrent.RWMutex = sync.RWMutex{} copyCurrent.Gauges = make(map[string]GaugeValue, len(current.Gauges)) for k, v := range current.Gauges {