From 6a3a939c4a4787b2d404391e6ff9477076382ad8 Mon Sep 17 00:00:00 2001 From: Steve Dee Date: Mon, 10 Mar 2014 12:18:18 -0700 Subject: [PATCH] Fix for duplicate vote responses --- include/v/vere.h | 1 + v/raft.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/v/vere.h b/include/v/vere.h index 99e4ee18a7..a0d120b807 100644 --- a/include/v/vere.h +++ b/include/v/vere.h @@ -473,6 +473,7 @@ c3_c* por_c; u2_rcon* ron_u; struct _u2_rnam* nex_u; + u2_bean vog; } u2_rnam; /* u2_opts: diff --git a/v/raft.c b/v/raft.c index d39fa1b85c..ecf7e319b8 100644 --- a/v/raft.c +++ b/v/raft.c @@ -349,7 +349,14 @@ _raft_revo_done(u2_rreq* req_u, c3_w suc_w) c3_assert(c3__revo == req_u->msg_u->typ_w); if ( suc_w ) { - raf_u->vot_w++; + if ( u2_no == ron_u->nam_u->vog ) { + ron_u->nam_u->vog = u2_yes; + raf_u->vot_w++; + } + else { + uL(fprintf(uH, "XX raft: duplicate response for %s [tem:%d]\n", + ron_u->nam_u->str_c, raf_u->tem_w)); + } } if ( raf_u->vot_w > raf_u->pop_w / 2 ) { uL(fprintf(uH, "raft: got majority of %d for term %d\n", @@ -1234,6 +1241,13 @@ _raft_start_election(u2_raft* raf_u) u2_sist_put("term", (c3_y*)&raf_u->tem_w, sizeof(c3_w)); uL(fprintf(uH, "raft: starting election [tem:%d]\n", raf_u->tem_w)); + { + u2_rnam* nam_u; + + for ( nam_u = raf_u->nam_u; nam_u; nam_u = nam_u->nex_u ) { + nam_u->vog = u2_no; + } + } raf_u->vot_w = 1; raf_u->vog_c = strdup(raf_u->str_c); u2_sist_put("vote", (c3_y*)raf_u->vog_c, strlen(raf_u->vog_c));