Skip to content

Commit

Permalink
Merge pull request #10277 from hashicorp/b-lock
Browse files Browse the repository at this point in the history
terraform: write lock on post state updates
  • Loading branch information
mitchellh authored Nov 21, 2016
2 parents c1e9a65 + b6687aa commit 43869c5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions terraform/eval_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ type EvalUpdateStateHook struct{}
func (n *EvalUpdateStateHook) Eval(ctx EvalContext) (interface{}, error) {
state, lock := ctx.State()

// Get a read lock so it doesn't change while we're calling this
lock.RLock()
defer lock.RUnlock()
// Get a full lock. Even calling something like WriteState can modify
// (prune) the state, so we need the full lock.
lock.Lock()
defer lock.Unlock()

// Call the hook
err := ctx.Hook(func(h Hook) (HookAction, error) {
Expand Down

0 comments on commit 43869c5

Please sign in to comment.