stats -- Clamp number of rotations to sane value and prevent from going into (very long) loop

This commit is contained in:
Eugene Bujak 2018-10-08 05:55:33 +03:00
parent 182fa37e5f
commit 0440ef016a
1 changed files with 3 additions and 0 deletions

View File

@ -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 {