raft: update lead for follower sm when receiving msgApp

Or follower may take `none` as its leader forever if it just launched
a failed election whose term is the same as the current leader.
This commit is contained in:
Yicheng Qin 2014-07-10 14:06:35 -07:00
parent edd8d7e534
commit 690edb2c56

View File

@ -411,6 +411,7 @@ func stepFollower(sm *stateMachine, m Message) bool {
m.To = sm.lead.Get()
sm.send(m)
case msgApp:
sm.lead.Set(m.From)
sm.handleAppendEntries(m)
case msgSnap:
sm.handleSnapshot(m)