Bump votes on restore

This commit is contained in:
Steve Dee 2014-03-07 19:25:03 -08:00
parent 139c46dd63
commit a5b23546a6

View File

@ -332,7 +332,7 @@ _raft_do_revo(u2_rcon* ron_u, const u2_rmsg* msg_u)
{ {
free(raf_u->vog_c); free(raf_u->vog_c);
raf_u->vog_c = strdup(ron_u->nam_u->str_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)); uL(fprintf(uH, "raft: granting vote to %s\n", raf_u->vog_c));
_raft_send_rasp(ron_u, 1); _raft_send_rasp(ron_u, 1);
} }
@ -1323,6 +1323,12 @@ _raft_foll_init(u2_raft* raf_u)
c3_assert(wri_i < siz_i); 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. // Bind the listener.
{ {
struct sockaddr_in add_u = uv_ip4_addr("0.0.0.0", u2_Host.ops_u.rop_s); struct sockaddr_in add_u = uv_ip4_addr("0.0.0.0", u2_Host.ops_u.rop_s);