terraform: acquire stopCh outside goroutine to ensure in lock
This commit is contained in:
parent
00232f0994
commit
3e771a674c
|
@ -811,7 +811,8 @@ func (c *Context) walk(
|
||||||
|
|
||||||
// Watch for a stop so we can call the provider Stop() API.
|
// Watch for a stop so we can call the provider Stop() API.
|
||||||
doneCh := make(chan struct{})
|
doneCh := make(chan struct{})
|
||||||
go c.watchStop(walker, doneCh)
|
stopCh := c.runContext.Done()
|
||||||
|
go c.watchStop(walker, doneCh, stopCh)
|
||||||
|
|
||||||
// Walk the real graph, this will block until it completes
|
// Walk the real graph, this will block until it completes
|
||||||
realErr := graph.Walk(walker)
|
realErr := graph.Walk(walker)
|
||||||
|
@ -906,12 +907,7 @@ func (c *Context) walk(
|
||||||
return walker, realErr
|
return walker, realErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) watchStop(walker *ContextGraphWalker, doneCh <-chan struct{}) {
|
func (c *Context) watchStop(walker *ContextGraphWalker, doneCh, stopCh <-chan struct{}) {
|
||||||
// Get the stop channel. runContext will never be nil since this should
|
|
||||||
// only be called within the context of an operation started with
|
|
||||||
// acquireRun
|
|
||||||
stopCh := c.runContext.Done()
|
|
||||||
|
|
||||||
// Wait for a stop or completion
|
// Wait for a stop or completion
|
||||||
select {
|
select {
|
||||||
case <-stopCh:
|
case <-stopCh:
|
||||||
|
|
Loading…
Reference in New Issue