diff --git a/server.go b/server.go index d25b8a3ada..b7a93031dc 100644 --- a/server.go +++ b/server.go @@ -189,11 +189,9 @@ func (s *Server) LastCommandName() string { // Retrieves the number of member servers in the consensus. func (s *Server) MemberCount() int { - count := 1 - for _, _ = range s.peers { - count++ - } - return count + s.mutex.Lock() + defer s.mutex.Unlock() + return len(s.peers) + 1 } // Retrieves the number of servers required to make a quorum.