mirror of https://github.com/status-im/consul.git
agent/checks: prevent overflow of backoff
This commit is contained in:
parent
d6ecd97d1d
commit
9a90400821
|
@ -120,7 +120,11 @@ func (c *CheckAlias) runQuery(stopCh chan struct{}) {
|
|||
|
||||
// Backoff if we have to
|
||||
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 {
|
||||
waitTime = checkAliasBackoffMaxWait
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue