Unverified Commit 9f2205fb authored by Ozan Tezcan's avatar Ozan Tezcan Committed by GitHub
Browse files

Revert change for timeout message (#136)

Revert change for sending timeout message.

Introduced by https://github.com/RedisLabs/raft/pull/127.
This PR deleted the check to prevent sending duplicate
timeout messages.
parent 733123ab
...@@ -750,7 +750,8 @@ int raft_recv_appendentries_response(raft_server_t *me, ...@@ -750,7 +750,8 @@ int raft_recv_appendentries_response(raft_server_t *me,
return 0; return 0;
} }
if (raft_get_transfer_leader(me) == raft_node_get_id(node) && if (!me->sent_timeout_now &&
raft_get_transfer_leader(me) == raft_node_get_id(node) &&
raft_get_current_idx(me) == resp->current_idx) { raft_get_current_idx(me) == resp->current_idx) {
me->cb.send_timeoutnow(me, me->udata, node); me->cb.send_timeoutnow(me, me->udata, node);
......
...@@ -4066,7 +4066,7 @@ int timeoutnow_sent = 0; ...@@ -4066,7 +4066,7 @@ int timeoutnow_sent = 0;
int cb_timeoutnow(raft_server_t* raft, void *udata, raft_node_t* node) int cb_timeoutnow(raft_server_t* raft, void *udata, raft_node_t* node)
{ {
timeoutnow_sent = 1; timeoutnow_sent++;
return 0; return 0;
} }
...@@ -4140,6 +4140,10 @@ void TestRaft_callback_timeoutnow_at_send_appendentries_response_if_up_to_date(C ...@@ -4140,6 +4140,10 @@ void TestRaft_callback_timeoutnow_at_send_appendentries_response_if_up_to_date(C
raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer);
CuAssertTrue(tc, 1 == timeoutnow_sent); CuAssertTrue(tc, 1 == timeoutnow_sent);
/* Verify we won't send timeout now message twice. */
raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer);
CuAssertTrue(tc, 1 == timeoutnow_sent);
} }
void TestRaft_leader_steps_down_if_there_is_no_quorum(CuTest * tc) void TestRaft_leader_steps_down_if_there_is_no_quorum(CuTest * tc)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment