fix: protect updating latencies/throughput slices in obd (#10611)

Additionally close the transferChan upon function exit.
This commit is contained in:
Harshavardhana
2020-10-01 09:50:08 -07:00
committed by GitHub
parent 3047121255
commit 98a08e1644
2 changed files with 8 additions and 7 deletions

View File

@@ -27,9 +27,6 @@ import (
"github.com/montanaflynn/stats"
)
var globalLatency = map[string]Latency{}
var globalThroughput = map[string]Throughput{}
// Latency holds latency information for write operations to the drive
type Latency struct {
Avg float64 `json:"avg_secs,omitempty"`
@@ -154,6 +151,7 @@ func GetOBDInfo(ctx context.Context, drive, fsPath string) (Latency, Throughput,
if minThroughput, err = stats.Min(throughputs); err != nil {
return Latency{}, Throughput{}, err
}
t := Throughput{
Avg: avgThroughput,
Percentile50: percentile50Throughput,
@@ -163,8 +161,5 @@ func GetOBDInfo(ctx context.Context, drive, fsPath string) (Latency, Throughput,
Max: maxThroughput,
}
globalLatency[drive] = l
globalThroughput[drive] = t
return l, t, nil
}