Skip to content

Commit

Permalink
Refactor: clean up voting change detection
Browse files Browse the repository at this point in the history
  • Loading branch information
willemt committed May 18, 2016
1 parent bdabd1d commit 2e2c15e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/raft_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ raft_entry_t* raft_get_entry_from_idx(raft_server_t* me_, int etyidx)
return log_get_at_idx(me->log, etyidx);
}

int raft_voting_change_is_in_progress(raft_server_t* me_)
{
return ((raft_server_private_t*)me_)->voting_cfg_change_log_idx != -1;
}

int raft_recv_appendentries_response(raft_server_t* me_,
raft_node_t* node,
msg_appendentries_response_t* r)
Expand Down Expand Up @@ -562,7 +567,7 @@ int raft_recv_entry(raft_server_t* me_,

/* Only one voting cfg change at a time */
if (raft_entry_is_voting_cfg_change(e))
if (-1 != me->voting_cfg_change_log_idx)
if (raft_voting_change_is_in_progress(me_))
return RAFT_ERR_ONE_VOTING_CHANGE_ONLY;

if (!raft_is_leader(me_))
Expand Down

0 comments on commit 2e2c15e

Please sign in to comment.