mirror of
https://github.com/LBRYFoundation/lbcd.git
synced 2025-08-23 17:47:24 +00:00
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
|
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.
|
// killed, and temporary directories removed.
|
||||||
//
|
//
|
||||||
// NOTE: This method and SetUp should always be called from the same goroutine
|
// This function MUST be called with the harness state mutex held (for writes).
|
||||||
// as they are not concurrent safe.
|
func (h *Harness) tearDown() error {
|
||||||
func (h *Harness) TearDown() error {
|
|
||||||
if h.Node != nil {
|
if h.Node != nil {
|
||||||
h.Node.Shutdown()
|
h.Node.Shutdown()
|
||||||
}
|
}
|
||||||
|
@ -278,6 +277,18 @@ func (h *Harness) TearDown() error {
|
||||||
return nil
|
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
|
// connectRPCClient attempts to establish an RPC connection to the created btcd
|
||||||
// process belonging to this Harness instance. If the initial connection
|
// process belonging to this Harness instance. If the initial connection
|
||||||
// attempt fails, this function will retry h.maxConnRetries times, backing off
|
// attempt fails, this function will retry h.maxConnRetries times, backing off
|
||||||
|
|
|
@ -140,7 +140,7 @@ func TearDownAll() error {
|
||||||
defer harnessStateMtx.Unlock()
|
defer harnessStateMtx.Unlock()
|
||||||
|
|
||||||
for _, harness := range testInstances {
|
for _, harness := range testInstances {
|
||||||
if err := harness.TearDown(); err != nil {
|
if err := harness.tearDown(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue