From f44336d57df2f1a8bfb26083402ee9bcd5ff7229 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 11 Jul 2016 23:07:21 -0400 Subject: [PATCH] consensus: don't print shared vars in cs.String() --- consensus/state.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/consensus/state.go b/consensus/state.go index d76c82969..4000b072f 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -268,7 +268,8 @@ func (cs *ConsensusState) SetEventSwitch(evsw *events.EventSwitch) { } func (cs *ConsensusState) String() string { - return Fmt("ConsensusState(H:%v R:%v S:%v", cs.Height, cs.Round, cs.Step) + // better not to access shared variables + return Fmt("ConsensusState") //(H:%v R:%v S:%v", cs.Height, cs.Round, cs.Step) } func (cs *ConsensusState) GetState() *sm.State { @@ -321,9 +322,7 @@ 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()