agent/checks: prevent overflow of backoff

pull/4320/head
Mitchell Hashimoto 6 years ago
parent d6ecd97d1d
commit 9a90400821
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A

@ -120,7 +120,11 @@ func (c *CheckAlias) runQuery(stopCh chan struct{}) {
// Backoff if we have to // Backoff if we have to
if attempt > checkAliasBackoffMin { if attempt > checkAliasBackoffMin {
waitTime := (1 << (attempt - checkAliasBackoffMin)) * time.Second shift := attempt - checkAliasBackoffMin
if shift > 31 {
shift = 31 // so we don't overflow to 0
}
waitTime := (1 << shift) * time.Second
if waitTime > checkAliasBackoffMaxWait { if waitTime > checkAliasBackoffMaxWait {
waitTime = checkAliasBackoffMaxWait waitTime = checkAliasBackoffMaxWait
} }

Loading…
Cancel
Save