Skip to content

Commit

Permalink
inmem: create a new RWMutex, because they are not safe to copy
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Apr 28, 2021
1 parent 111a475 commit 6dab912
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions inmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6dab912

Please sign in to comment.