Skip to content

Commit

Permalink
Take the state lock in checkBarrierRotate, and don't save on seal (#1…
Browse files Browse the repository at this point in the history
…1028)

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

* defer
  • Loading branch information
sgmiller authored Mar 1, 2021
1 parent 4e7283c commit ed62faf
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions vault/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ed62faf

Please sign in to comment.