From a5b23546a6eafa96e2b9a4b38e3d6626429e3e81 Mon Sep 17 00:00:00 2001 From: Steve Dee Date: Fri, 7 Mar 2014 19:25:03 -0800 Subject: [PATCH] Bump votes on restore --- v/raft.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/v/raft.c b/v/raft.c index f0d030f271..5e76da28d1 100644 --- a/v/raft.c +++ b/v/raft.c @@ -332,7 +332,7 @@ _raft_do_revo(u2_rcon* ron_u, const u2_rmsg* msg_u) { free(raf_u->vog_c); raf_u->vog_c = strdup(ron_u->nam_u->str_c); - u2_sist_put("vote", raf_u->vog_c, strlen(raf_u->vog_c)); + u2_sist_put("vote", (c3_y*)raf_u->vog_c, strlen(raf_u->vog_c)); uL(fprintf(uH, "raft: granting vote to %s\n", raf_u->vog_c)); _raft_send_rasp(ron_u, 1); } @@ -1323,6 +1323,12 @@ _raft_foll_init(u2_raft* raf_u) c3_assert(wri_i < siz_i); } + // Bump votes if appropriate. + if ( 0 == strcmp(raf_u->str_c, raf_u->vog_c) ) { + raf_u->vot_w = 1; + raf_u->typ_e = u2_raty_cand; + } + // Bind the listener. { struct sockaddr_in add_u = uv_ip4_addr("0.0.0.0", u2_Host.ops_u.rop_s);