From a954821b9804464f89dc033f65c18af217cb6d61 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 2 Apr 2021 12:50:46 +0300 Subject: [PATCH] consensus: make Shutdown a no-op if not started It makes client code a bit simpler, we can just issue a Shutdown() request without thinking much about it (but only once of course). --- pkg/consensus/consensus.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/consensus/consensus.go b/pkg/consensus/consensus.go index 2ced9fca8..6fc898047 100644 --- a/pkg/consensus/consensus.go +++ b/pkg/consensus/consensus.go @@ -252,8 +252,10 @@ func (s *service) Start() { // Shutdown implements Service interface. func (s *service) Shutdown() { - close(s.quit) - <-s.finished + if s.started.Load() { + close(s.quit) + <-s.finished + } } func (s *service) eventLoop() {