Take the state lock in checkBarrierRotate, and don't save on seal (#11028)

* Use the state lock, and don't bother a last minute check on seal

* defer
This commit is contained in:
Scott Miller 2021-03-01 16:32:17 -06:00 committed by GitHub
parent 90ee789afe
commit 08d8f65e01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 5 deletions

View File

@ -1763,11 +1763,6 @@ func (c *Core) sealInternalWithOptions(grabStateLock, keepHALock, performCleanup
c.logger.Info("marked as sealed")
// Give the barrier a chance to persist encryption counts
if c.autoRotateCancel != nil {
c.checkBarrierAutoRotate(c.activeContext)
}
// Clear forwarding clients
c.requestForwardingConnectionLock.Lock()
c.clearForwardingClients()
@ -2762,6 +2757,8 @@ func (c *Core) autoRotateBarrierLoop(ctx context.Context) {
}
func (c *Core) checkBarrierAutoRotate(ctx context.Context) {
c.stateLock.RLock()
defer c.stateLock.RUnlock()
if c.isPrimary() {
reason, err := c.barrier.CheckBarrierAutoRotate(ctx)
if err != nil {