From b242b15d40090f53dbe2646ac1773f88f37fe238 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 4 Jul 2018 13:44:51 +0400 Subject: [PATCH] wait until WAL closes the autogroup Refs #1839 --- consensus/reactor.go | 1 + consensus/state.go | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/consensus/reactor.go b/consensus/reactor.go index 54407ae1e..1cac32b80 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -80,6 +80,7 @@ func (conR *ConsensusReactor) OnStop() { conR.BaseReactor.OnStop() conR.unsubscribeFromBroadcastEvents() conR.conS.Stop() + conR.conS.Wait() } // SwitchToConsensus switches from fast_sync mode to consensus mode. diff --git a/consensus/state.go b/consensus/state.go index d013f4231..e4b360e08 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -314,13 +314,8 @@ func (cs *ConsensusState) startRoutines(maxSteps int) { // OnStop implements cmn.Service. It stops all routines and waits for the WAL to finish. func (cs *ConsensusState) OnStop() { - cs.BaseService.OnStop() - cs.evsw.Stop() - cs.timeoutTicker.Stop() - - cs.wal.Stop() } // Wait waits for the the main routine to return. @@ -600,6 +595,7 @@ func (cs *ConsensusState) receiveRoutine(maxSteps int) { // close wal now that we're done writing to it cs.wal.Stop() + cs.wal.Wait() close(cs.done) return