|
@ -493,12 +493,19 @@ func (cs *State) loadWalFile(ctx context.Context) error { |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (cs *State) getOnStopCh() chan *cstypes.RoundState { |
|
|
|
|
|
cs.mtx.RLock() |
|
|
|
|
|
defer cs.mtx.RUnlock() |
|
|
|
|
|
|
|
|
|
|
|
return cs.onStopCh |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// OnStop implements service.Service.
|
|
|
// OnStop implements service.Service.
|
|
|
func (cs *State) OnStop() { |
|
|
func (cs *State) OnStop() { |
|
|
// If the node is committing a new block, wait until it is finished!
|
|
|
// If the node is committing a new block, wait until it is finished!
|
|
|
if cs.GetRoundState().Step == cstypes.RoundStepCommit { |
|
|
if cs.GetRoundState().Step == cstypes.RoundStepCommit { |
|
|
select { |
|
|
select { |
|
|
case <-cs.onStopCh: |
|
|
|
|
|
|
|
|
case <-cs.getOnStopCh(): |
|
|
case <-time.After(cs.config.TimeoutCommit): |
|
|
case <-time.After(cs.config.TimeoutCommit): |
|
|
cs.logger.Error("OnStop: timeout waiting for commit to finish", "time", cs.config.TimeoutCommit) |
|
|
cs.logger.Error("OnStop: timeout waiting for commit to finish", "time", cs.config.TimeoutCommit) |
|
|
} |
|
|
} |
|
|