From 17b96ca95ffd4cbf8af762a974fc8b18f2c1b993 Mon Sep 17 00:00:00 2001 From: wmin0 Date: Fri, 4 Jan 2019 16:28:47 +0800 Subject: core: syncer: safe spawn go routine (#399) --- core/syncer/consensus.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'core/syncer/consensus.go') diff --git a/core/syncer/consensus.go b/core/syncer/consensus.go index d334bbd..8852a47 100644 --- a/core/syncer/consensus.go +++ b/core/syncer/consensus.go @@ -623,10 +623,13 @@ func (con *Consensus) resizeByNumChains(numChains uint32) { // Resize the pool of blocks. con.blocks = append(con.blocks, types.ByPosition{}) // Resize agreement modules. - a := newAgreement(con.receiveChan, con.pullChan, con.nodeSetCache, - &con.agreementWaitGroup, con.logger) + a := newAgreement(con.receiveChan, con.pullChan, con.nodeSetCache, con.logger) con.agreements = append(con.agreements, a) - go a.run() + con.agreementWaitGroup.Add(1) + go func() { + defer con.agreementWaitGroup.Done() + a.run() + }() } } } -- cgit v1.2.3