From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 122DE430415 for ; Thu, 3 Sep 2020 02:33:27 +0300 (MSK) From: Vladislav Shpilevoy Date: Thu, 3 Sep 2020 01:33:17 +0200 Message-Id: <918ce76fb1447b8f359d2382ed892e6d97c428b1.1599089353.git.v.shpilevoy@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 7/8] [tosquash] raft: pass source instance_id to raft_process_msg() List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, sergepetrenko@tarantool.org, gorcunov@gmail.com Instance ID of the sender is needed in order to - be able to vote for him; - be able to remember its ID as leader ID, when it is a leader. --- src/box/applier.cc | 9 ++++----- src/box/raft.c | 3 ++- src/box/raft.h | 8 ++++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/box/applier.cc b/src/box/applier.cc index 17e3ce1ae..8de2f799b 100644 --- a/src/box/applier.cc +++ b/src/box/applier.cc @@ -898,7 +898,7 @@ err: } static int -apply_raft_row(struct xrow_header *row) +applier_handle_raft(struct applier *applier, struct xrow_header *row) { assert(iproto_type_is_raft_request(row->type)); @@ -906,9 +906,7 @@ apply_raft_row(struct xrow_header *row) struct vclock candidate_clock; if (xrow_decode_raft(row, &req, &candidate_clock) != 0) return -1; - - raft_process_msg(&req); - + raft_process_msg(&req, applier->instance_id); return 0; } @@ -1262,7 +1260,8 @@ applier_subscribe(struct applier *applier) if (first_row->lsn == 0) { if (unlikely(iproto_type_is_raft_request( first_row->type))) { - if (apply_raft_row(first_row) != 0) + if (applier_handle_raft(applier, + first_row) != 0) diag_raise(); } else { applier_signal_ack(applier); diff --git a/src/box/raft.c b/src/box/raft.c index fd8853d6e..1acffb677 100644 --- a/src/box/raft.c +++ b/src/box/raft.c @@ -78,8 +78,9 @@ raft_process_recovery(const struct raft_request *req) } void -raft_process_msg(const struct raft_request *req) +raft_process_msg(const struct raft_request *req, uint32_t source) { + (void)source; if (req->term > raft.term) { // Update term. // The logic will be similar, but the code diff --git a/src/box/raft.h b/src/box/raft.h index 0bf87e64b..d875707de 100644 --- a/src/box/raft.h +++ b/src/box/raft.h @@ -75,9 +75,13 @@ raft_is_enabled(void) void raft_process_recovery(const struct raft_request *req); -/** Process a raft status message coming from the network. */ +/** + * Process a raft status message coming from the network. + * @param req Raft request. + * @param source Instance ID of the message sender. + */ void -raft_process_msg(const struct raft_request *req); +raft_process_msg(const struct raft_request *req, uint32_t source); /** * Broadcast the changes in this instance's raft status to all -- 2.21.1 (Apple Git-122.3)