VAULT-8436 remove <-time.After statements in for loops (#18818)

* replace time.After with ticker in loops

* add semgrep rule

* update to use timers

* remove stop
This commit is contained in:
miagilepner
2023-02-06 17:49:01 +01:00
committed by GitHub
parent 192baa88db
commit 13caa0842e
10 changed files with 63 additions and 16 deletions

View File

@@ -2319,9 +2319,11 @@ func (c *ServerCommand) storageMigrationActive(backend physical.Backend) bool {
}
c.logger.Warn("storage migration check error", "error", err.Error())
timer := time.NewTimer(2 * time.Second)
select {
case <-time.After(2 * time.Second):
case <-timer.C:
case <-c.ShutdownCh:
timer.Stop()
return true
}
}
@@ -2609,10 +2611,12 @@ func runUnseal(c *ServerCommand, core *vault.Core, ctx context.Context) {
}
c.logger.Warn("failed to unseal core", "error", err)
timer := time.NewTimer(5 * time.Second)
select {
case <-c.ShutdownCh:
timer.Stop()
return
case <-time.After(5 * time.Second):
case <-timer.C:
}
}
}