Commit 6e348ebe authored by Dulloor's avatar Dulloor
Browse files

Apply entries lazily even if leader.

parent cefdd08c
...@@ -144,7 +144,11 @@ int raft_periodic(raft_server_t* me_, int msec_since_last_period) ...@@ -144,7 +144,11 @@ int raft_periodic(raft_server_t* me_, int msec_since_last_period)
me->timeout_elapsed += msec_since_last_period; me->timeout_elapsed += msec_since_last_period;
if (me->state == RAFT_STATE_LEADER) 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) if (me->request_timeout <= me->timeout_elapsed)
{ {
raft_send_appendentries_all(me_); raft_send_appendentries_all(me_);
......
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