Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Hoffman committed Sep 1, 2017
1 parent 67105c5 commit c523a00
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions vault/expiration.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,16 @@ func (m *ExpirationManager) Restore(errorFunc func(), loadDelay time.Duration) (
time.Sleep(loadDelay)
}

m.processRestore(leaseID, result, errs)
m.lockLease(leaseID)
_, err := m.loadEntryInternal(leaseID, true)
m.unlockLease(leaseID)
if err != nil {
errs <- err
return
}

// Write results out to the result channel
result <- struct{}{}

// quit early
case <-quit:
Expand Down Expand Up @@ -370,28 +379,14 @@ func (m *ExpirationManager) Restore(errorFunc func(), loadDelay time.Duration) (
// Clear our the restored entries and turn off restore mode
m.restoreModeLock.Lock()
m.restoreLoaded = sync.Map{}
m.restoreLocks = nil
atomic.StoreInt64(&m.restoreMode, 0)
m.restoreModeLock.Unlock()

m.logger.Info("expiration: lease restore complete")
return nil
}

func (m *ExpirationManager) processRestore(leaseID string, resultChan chan struct{}, errChan chan error) {
// Take the lease lock
m.lockLease(leaseID)
defer m.unlockLease(leaseID)

_, err := m.loadEntryInternal(leaseID, true)
if err != nil {
errChan <- err
return
}

// Write results out to the result channel
resultChan <- struct{}{}
}

// Stop is used to prevent further automatic revocations.
// This must be called before sealing the view.
func (m *ExpirationManager) Stop() error {
Expand Down

0 comments on commit c523a00

Please sign in to comment.