Skip to content

Commit

Permalink
Merge pull request #101 from Mistobaan/master
Browse files Browse the repository at this point in the history
add mutex
  • Loading branch information
xiang90 committed Aug 7, 2013
2 parents d467482 + e5530c4 commit 0a18dcf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,15 @@ func (s *Server) QuorumSize() int {

// Retrieves the election timeout.
func (s *Server) ElectionTimeout() time.Duration {
s.mutex.RLock()
defer s.mutex.RUnlock()
return s.electionTimeout
}

// Sets the election timeout.
func (s *Server) SetElectionTimeout(duration time.Duration) {
s.mutex.Lock()
defer s.mutex.Unlock()
s.electionTimeout = duration
}

Expand All @@ -286,6 +290,8 @@ func (s *Server) SetElectionTimeout(duration time.Duration) {

// Retrieves the heartbeat timeout.
func (s *Server) HeartbeatTimeout() time.Duration {
s.mutex.RLock()
defer s.mutex.RUnlock()
return s.heartbeatTimeout
}

Expand Down Expand Up @@ -419,8 +425,8 @@ func (s *Server) readConf() error {
func (s *Server) Stop() {
s.send(&stopValue)
s.mutex.Lock()
defer s.mutex.Unlock()
s.log.close()
s.mutex.Unlock()
}

// Checks if the server is currently running.
Expand Down

0 comments on commit 0a18dcf

Please sign in to comment.