raft: Use <= instead of < for heartbeat ticks.

In code outside the raft package, we cannot call raft.bcastHeartbeat
directly. Instead, to control heartbeats we set heartbeatInterval to 1
and call Tick().
This commit is contained in:
Ben Darnell 2015-01-14 15:27:32 -05:00
parent 232927d9dc
commit 9972e62d94
2 changed files with 2 additions and 2 deletions

View File

@ -346,7 +346,7 @@ func (r *raft) tickElection() {
// tickHeartbeat is run by leaders to send a MsgBeat after r.heartbeatTimeout.
func (r *raft) tickHeartbeat() {
r.elapsed++
if r.elapsed > r.heartbeatTimeout {
if r.elapsed >= r.heartbeatTimeout {
r.elapsed = 0
r.Step(pb.Message{From: r.id, Type: pb.MsgBeat})
}

View File

@ -120,7 +120,7 @@ func TestLeaderBcastBeat(t *testing.T) {
r.appendEntry(pb.Entry{Index: uint64(i) + 1})
}
for i := 0; i <= hi; i++ {
for i := 0; i < hi; i++ {
r.tick()
}