From 2e2c15ea54dc1bcbecbceba2b5ec1d2dc6bfe989 Mon Sep 17 00:00:00 2001 From: Willem Thiart Date: Wed, 18 May 2016 12:23:14 +0100 Subject: [PATCH] Refactor: clean up voting change detection --- src/raft_server.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/raft_server.c b/src/raft_server.c index 00b1425b..3d3c4152 100644 --- a/src/raft_server.c +++ b/src/raft_server.c @@ -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) @@ -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_))