aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-10-29 14:23:39 +0800
committerGitHub <noreply@github.com>2018-10-29 14:23:39 +0800
commitdcc2319797d3ab78ff0611b82c56d43803675e3c (patch)
tree625e87343ff1f57e5ed54ee6cb2b3cf0a323edc7
parent843f43bf245f0398fc581e885943661967ca1bc0 (diff)
downloaddexon-consensus-dcc2319797d3ab78ff0611b82c56d43803675e3c.tar
dexon-consensus-dcc2319797d3ab78ff0611b82c56d43803675e3c.tar.gz
dexon-consensus-dcc2319797d3ab78ff0611b82c56d43803675e3c.tar.bz2
dexon-consensus-dcc2319797d3ab78ff0611b82c56d43803675e3c.tar.lz
dexon-consensus-dcc2319797d3ab78ff0611b82c56d43803675e3c.tar.xz
dexon-consensus-dcc2319797d3ab78ff0611b82c56d43803675e3c.tar.zst
dexon-consensus-dcc2319797d3ab78ff0611b82c56d43803675e3c.zip
core: Fix goroutine leaks (#270)
-rw-r--r--core/configuration-chain.go8
-rw-r--r--core/consensus.go1
2 files changed, 8 insertions, 1 deletions
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
}
diff --git a/core/consensus.go b/core/consensus.go
index 5ad37a9..938337f 100644
--- a/core/consensus.go
+++ b/core/consensus.go
@@ -935,6 +935,7 @@ func (con *Consensus) processBlock(block *types.Block) (err error) {
if err = con.db.Update(*b); err != nil {
panic(err)
}
+ con.cfgModule.untouchTSigHash(b.Hash)
// TODO(mission): clone types.FinalizationResult
con.app.BlockDelivered(b.Hash, b.Finalization)
}