Browse Source

raft: fix pendingConf

Xiang Li 11 years ago
parent
commit
d293c4915c
1 changed files with 7 additions and 0 deletions
  1. 7 0
      raft/raft.go

+ 7 - 0
raft/raft.go

@@ -203,6 +203,7 @@ func (sm *stateMachine) becomeFollower(term, lead int) {
 	sm.term = term
 	sm.term = term
 	sm.lead = lead
 	sm.lead = lead
 	sm.state = stateFollower
 	sm.state = stateFollower
+	sm.pendingConf = false
 }
 }
 
 
 func (sm *stateMachine) becomeCandidate() {
 func (sm *stateMachine) becomeCandidate() {
@@ -224,6 +225,12 @@ func (sm *stateMachine) becomeLeader() {
 	sm.reset()
 	sm.reset()
 	sm.lead = sm.addr
 	sm.lead = sm.addr
 	sm.state = stateLeader
 	sm.state = stateLeader
+
+	for _, e := range sm.log.ents[sm.log.committed:] {
+		if e.Type == config {
+			sm.pendingConf = true
+		}
+	}
 }
 }
 
 
 func (sm *stateMachine) Msgs() []Message {
 func (sm *stateMachine) Msgs() []Message {