[Tarantool-patches] [PATCH v3] raft: make sure the voking mask is wide enough
Serge Petrenko
sergepetrenko at tarantool.org
Fri Oct 30 11:39:48 MSK 2020
30.10.2020 11:30, Cyrill Gorcunov пишет:
> The vote_mask is declared as uint32_t which is highly coupled
> with VCLOCK_MAX, lets add a compile time test to be sure.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
> ---
> v2:
> Use CHAR_BIT instead of hardcoded bits number
>
> src/box/raft.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> Index: tarantool.git/src/box/raft.c
> ===================================================================
> --- tarantool.git.orig/src/box/raft.c
> +++ tarantool.git/src/box/raft.c
> @@ -1061,4 +1061,10 @@ raft_init(void)
> {
> ev_timer_init(&raft.timer, raft_sm_schedule_new_election_cb, 0, 0);
> rlist_create(&raft.on_update);
> +
> + /*
> + * Make sure there is enough bits to track all replicas.
> + */
> + static_assert(sizeof(raft.vote_mask) * CHAR_BIT >= VCLOCK_MAX,
> + "RAFT: vote_mask is too short");
> }
Thanks for the fix! LGTM.
--
Serge Petrenko
More information about the Tarantool-patches
mailing list