rpctest: Prevent race during teardown.
This commit is contained in:
parent
53edcec224
commit
cb05e9b9cf
2 changed files with 16 additions and 5 deletions
|
@ -255,12 +255,11 @@ func (h *Harness) SetUp(createTestChain bool, numMatureOutputs uint32) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// TearDown stops the running rpc test instance. All created processes are
|
||||
// tearDown stops the running rpc test instance. All created processes are
|
||||
// killed, and temporary directories removed.
|
||||
//
|
||||
// NOTE: This method and SetUp should always be called from the same goroutine
|
||||
// as they are not concurrent safe.
|
||||
func (h *Harness) TearDown() error {
|
||||
// This function MUST be called with the harness state mutex held (for writes).
|
||||
func (h *Harness) tearDown() error {
|
||||
if h.Node != nil {
|
||||
h.Node.Shutdown()
|
||||
}
|
||||
|
@ -278,6 +277,18 @@ func (h *Harness) TearDown() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// TearDown stops the running rpc test instance. All created processes are
|
||||
// killed, and temporary directories removed.
|
||||
//
|
||||
// NOTE: This method and SetUp should always be called from the same goroutine
|
||||
// as they are not concurrent safe.
|
||||
func (h *Harness) TearDown() error {
|
||||
harnessStateMtx.Lock()
|
||||
defer harnessStateMtx.Unlock()
|
||||
|
||||
return h.tearDown()
|
||||
}
|
||||
|
||||
// connectRPCClient attempts to establish an RPC connection to the created btcd
|
||||
// process belonging to this Harness instance. If the initial connection
|
||||
// attempt fails, this function will retry h.maxConnRetries times, backing off
|
||||
|
|
|
@ -140,7 +140,7 @@ func TearDownAll() error {
|
|||
defer harnessStateMtx.Unlock()
|
||||
|
||||
for _, harness := range testInstances {
|
||||
if err := harness.TearDown(); err != nil {
|
||||
if err := harness.tearDown(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue