From da3c543ce218ae31e9a10faada491e6465f8e47b Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Thu, 21 Mar 2019 14:39:35 +0100 Subject: [PATCH] Revert "attempt copying slice" This reverts commit 0d4d40513fccd31b9cdc4db369aa87e87c529be4. --- monitor/metrics/window.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/monitor/metrics/window.go b/monitor/metrics/window.go index 05f7db7f..27d3e072 100644 --- a/monitor/metrics/window.go +++ b/monitor/metrics/window.go @@ -74,7 +74,9 @@ func (mw *Window) All() []*api.Metric { mw.wMu.Lock() // get to position so window.Do starts on the correct value mw.window = mw.window.Next() + mw.wMu.Unlock() + mw.wMu.RLock() values := make([]*api.Metric, 0, mw.window.Len()) mw.window.Do(func(v interface{}) { if i, ok := v.(*api.Metric); ok { @@ -82,11 +84,8 @@ func (mw *Window) All() []*api.Metric { values = append([]*api.Metric{i}, values...) } }) - mw.window = mw.window.Prev() - mw.wMu.Unlock() - copyValues := make([]*api.Metric, len(values)) - copy(copyValues, values) - return copyValues + mw.wMu.RUnlock() + return values } // Distribution returns the deltas between all the current