terraform: defer unlock of lock in Stop to enure it always unlocks

This commit is contained in:
Mitchell Hashimoto 2017-01-30 08:35:10 -08:00
parent 83cc54bfbe
commit 5b42781117
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
1 changed files with 1 additions and 1 deletions

View File

@ -636,6 +636,7 @@ func (c *Context) Stop() {
log.Printf("[WARN] terraform: Stop called, initiating interrupt sequence") log.Printf("[WARN] terraform: Stop called, initiating interrupt sequence")
c.l.Lock() c.l.Lock()
defer c.l.Unlock()
// If we're running, then stop // If we're running, then stop
if c.runContextCancel != nil { if c.runContextCancel != nil {
@ -652,7 +653,6 @@ func (c *Context) Stop() {
// Grab the condition var before we exit // Grab the condition var before we exit
if cond := c.runCond; cond != nil { if cond := c.runCond; cond != nil {
cond.Wait() cond.Wait()
c.l.Unlock()
} }
log.Printf("[WARN] terraform: stop complete") log.Printf("[WARN] terraform: stop complete")