Skip to content

Commit

Permalink
move state creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Kassouf committed Mar 18, 2019
1 parent a774f20 commit f736590
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions vault/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ func (m *RollbackManager) triggerRollbacks() {
// startRollback is used to start an async rollback attempt.
// This must be called with the inflightLock held.
func (m *RollbackManager) startOrLookupRollback(ctx context.Context, fullPath string, grabStatelock bool) *rollbackState {
m.inflightLock.Lock()
defer m.inflightLock.Unlock()
rsInflight, ok := m.inflight[fullPath]
if ok {
return rsInflight
}

rs := &rollbackState{
rollbackFunc: func(ctx context.Context) error {
ns, err := namespace.FromContext(ctx)
Expand Down Expand Up @@ -189,13 +196,6 @@ func (m *RollbackManager) startOrLookupRollback(ctx context.Context, fullPath st
},
}

m.inflightLock.Lock()
defer m.inflightLock.Unlock()
rsInflight, ok := m.inflight[fullPath]
if ok {
return rsInflight
}

// If no inflight rollback is already running, kick one off
m.inflight[fullPath] = rs
rs.Add(1)
Expand Down

0 comments on commit f736590

Please sign in to comment.