From 0440ef016afb5b3ef9619481df1288fc36257529 Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Mon, 8 Oct 2018 05:55:33 +0300 Subject: [PATCH] stats -- Clamp number of rotations to sane value and prevent from going into (very long) loop --- stats.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stats.go b/stats.go index f06380d2..c3b69126 100644 --- a/stats.go +++ b/stats.go @@ -107,6 +107,9 @@ func isConnRefused(err error) bool { } func statsRotate(periodic *periodicStats, now time.Time, rotations int64) { + if rotations > statsHistoryElements { + rotations = statsHistoryElements + } // calculate how many times we should rotate for r := int64(0); r < rotations; r++ { for key, values := range periodic.Entries {