core: MockProvider and MockProvisioner can't lock in Stop
The only reasonable usage of these methods is for them to run concurrently with other methods, so we mustn't hold a lock to do this work. For tests that deal with stopping, it's the test's own responsibility to deal with any concurrency issues that arise from their StopFns running concurrently with other mock functions.
This commit is contained in:
parent
21071fb679
commit
032f908f4a
|
@ -226,8 +226,10 @@ func (p *MockProvider) Configure(r providers.ConfigureRequest) providers.Configu
|
|||
}
|
||||
|
||||
func (p *MockProvider) Stop() error {
|
||||
p.Lock()
|
||||
defer p.Unlock()
|
||||
// We intentionally don't lock in this one because the whole point of this
|
||||
// method is to be called concurrently with another operation that can
|
||||
// be cancelled. The provider itself is responsible for handling
|
||||
// any concurrency concerns in this case.
|
||||
|
||||
p.StopCalled = true
|
||||
if p.StopFn != nil {
|
||||
|
|
|
@ -119,8 +119,10 @@ func (p *MockProvisioner) ProvisionResource(r provisioners.ProvisionResourceRequ
|
|||
}
|
||||
|
||||
func (p *MockProvisioner) Stop() error {
|
||||
p.Lock()
|
||||
defer p.Unlock()
|
||||
// We intentionally don't lock in this one because the whole point of this
|
||||
// method is to be called concurrently with another operation that can
|
||||
// be cancelled. The provisioner itself is responsible for handling
|
||||
// any concurrency concerns in this case.
|
||||
|
||||
p.StopCalled = true
|
||||
if p.StopFn != nil {
|
||||
|
|
Loading…
Reference in New Issue