consensus: fix race from OnStop accessing cs.Height

This commit is contained in:
Ethan Buchman 2016-07-11 20:54:32 -04:00
parent e4c795f15c
commit dd788c5631
1 changed files with 3 additions and 0 deletions

View File

@ -321,7 +321,10 @@ func (cs *ConsensusState) startRoutines(maxSteps int) {
}
func (cs *ConsensusState) OnStop() {
cs.mtx.Lock() // NOTE: OnStop prints the cs.Height, which might be concurrently updated ...
cs.QuitService.OnStop()
cs.mtx.Unlock()
if cs.wal != nil && cs.IsRunning() {
cs.wal.Wait()
}