raft: fix leaderID error when state changed

pull/2415/head
xiaost 2015-04-24 22:23:45 +08:00
parent d058ab9c59
commit e521ac9b73
1 changed files with 3 additions and 0 deletions

View File

@ -1023,6 +1023,9 @@ func (l *Log) candidateLoop(closing <-chan struct{}) State {
case <-l.terms:
return Follower
case <-elected:
l.lock()
l.leaderID = l.id
l.unlock()
return Leader
case ch := <-l.Clock.AfterElectionTimeout():
close(ch)