mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 10:12:35 +00:00
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:
@@ -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:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user