From dcc2319797d3ab78ff0611b82c56d43803675e3c Mon Sep 17 00:00:00 2001 From: Jimmy Hu Date: Mon, 29 Oct 2018 14:23:39 +0800 Subject: core: Fix goroutine leaks (#270) --- core/configuration-chain.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'core/configuration-chain.go') diff --git a/core/configuration-chain.go b/core/configuration-chain.go index 559eac0..bf24c31 100644 --- a/core/configuration-chain.go +++ b/core/configuration-chain.go @@ -205,6 +205,12 @@ func (cc *configurationChain) touchTSigHash(hash common.Hash) (first bool) { return !exist } +func (cc *configurationChain) untouchTSigHash(hash common.Hash) { + cc.tsigReady.L.Lock() + defer cc.tsigReady.L.Unlock() + delete(cc.tsigTouched, hash) +} + func (cc *configurationChain) runTSig( round uint64, hash common.Hash) ( crypto.Signature, error) { @@ -240,10 +246,10 @@ func (cc *configurationChain) runTSig( signature, err = cc.tsig[hash].signature() return err == ErrNotEnoughtPartialSignatures }() { + // TODO(jimmy-dexon): add a timeout here. cc.tsigReady.Wait() } delete(cc.tsig, hash) - delete(cc.tsigTouched, hash) if err != nil { return crypto.Signature{}, err } -- cgit v1.2.3