Commit 14d65292 authored by Willem Thiart's avatar Willem Thiart
Browse files

Appendentries for every state type

parent 13fb07e9
......@@ -133,23 +133,10 @@ int raft_periodic(raft_server_t* me_, int msec_since_last_period)
{
raft_server_private_t* me = (raft_server_private_t*)me_;
switch (me->state)
{
case RAFT_STATE_FOLLOWER:
if (me->last_applied_idx < me->commit_idx)
if (-1 == raft_apply_entry(me_))
return -1;
break;
}
me->timeout_elapsed += msec_since_last_period;
if (me->state == RAFT_STATE_LEADER)
{
if (me->last_applied_idx < me->commit_idx)
if (-1 == raft_apply_entry(me_))
return -1;
if (me->request_timeout <= me->timeout_elapsed)
{
raft_send_appendentries_all(me_);
......@@ -159,6 +146,10 @@ int raft_periodic(raft_server_t* me_, int msec_since_last_period)
else if (me->election_timeout <= me->timeout_elapsed)
raft_election_start(me_);
if (me->last_applied_idx < me->commit_idx)
if (-1 == raft_apply_entry(me_))
return -1;
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment