From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp32.i.mail.ru (smtp32.i.mail.ru [94.100.177.92]) (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 D09F2469719 for ; Tue, 22 Sep 2020 11:48:06 +0300 (MSK) References: <17979db071a67d8e5f299fd405095dc14a507b3c.1599693319.git.v.shpilevoy@tarantool.org> <6ca694f2-2e84-fcf3-ca46-15e188bfdf10@tarantool.org> <5d17798d-e8aa-9a33-3e13-08c66d3cf710@tarantool.org> From: Serge Petrenko Message-ID: <7d25cba8-5af9-0ecd-6087-9e0efd63bfd4@tarantool.org> Date: Tue, 22 Sep 2020 11:48:06 +0300 MIME-Version: 1.0 In-Reply-To: <5d17798d-e8aa-9a33-3e13-08c66d3cf710@tarantool.org> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: ru Subject: Re: [Tarantool-patches] [PATCH v2 08/11] raft: relay status updates to followers List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org, gorcunov@gmail.com 22.09.2020 01:47, Vladislav Shpilevoy пишет: > Consider my commit on top of your changes: > > ==================== > [tosquash] raft: vclock should be out parameter; reduce diff > > Firstly I made raft_serialize_for_network() use its vclock > parameter as an out parameter. Because it is Raft's deal what > vclock it wants to send. It can't be dictated by the function > caller. > > Secondly, I renamed data back to buf in xrow.c in order to reduce > diff from the previous patches. LGTM > > diff --git a/src/box/raft.c b/src/box/raft.c > index c2ef9ff39..2bf8490ea 100644 > --- a/src/box/raft.c > +++ b/src/box/raft.c > @@ -115,8 +115,10 @@ raft_serialize_for_network(struct raft_request *req, struct vclock *vclock) > * Raft does not own vclock, so it always expects it passed externally. > * Vclock is sent out only by candidate instances. > */ > - if (req->state == RAFT_STATE_CANDIDATE) > + if (req->state == RAFT_STATE_CANDIDATE) { > req->vclock = vclock; > + vclock_copy(vclock, &replicaset.vclock); > + } > } > > void > diff --git a/src/box/xrow.c b/src/box/xrow.c > index 250794a3e..da5c6ffae 100644 > --- a/src/box/xrow.c > +++ b/src/box/xrow.c > @@ -996,26 +996,24 @@ xrow_encode_raft(struct xrow_header *row, struct region *region, > row->body[0].iov_base = buf; > row->group_id = GROUP_LOCAL; > row->bodycnt = 1; > - char *data = buf; > + const char *begin = buf; > > - data = mp_encode_map(data, map_size); > - data = mp_encode_uint(data, IPROTO_RAFT_TERM); > - data = mp_encode_uint(data, r->term); > + buf = mp_encode_map(buf, map_size); > + buf = mp_encode_uint(buf, IPROTO_RAFT_TERM); > + buf = mp_encode_uint(buf, r->term); > if (r->vote != 0) { > - data = mp_encode_uint(data, IPROTO_RAFT_VOTE); > - data = mp_encode_uint(data, r->vote); > + buf = mp_encode_uint(buf, IPROTO_RAFT_VOTE); > + buf = mp_encode_uint(buf, r->vote); > } > if (r->state != 0) { > - data = mp_encode_uint(data, IPROTO_RAFT_STATE); > - data = mp_encode_uint(data, r->state); > + buf = mp_encode_uint(buf, IPROTO_RAFT_STATE); > + buf = mp_encode_uint(buf, r->state); > } > if (r->vclock != NULL) { > - data = mp_encode_uint(data, IPROTO_RAFT_VCLOCK); > - data = mp_encode_vclock_ignore0(data, r->vclock); > + buf = mp_encode_uint(buf, IPROTO_RAFT_VCLOCK); > + buf = mp_encode_vclock_ignore0(buf, r->vclock); > } > - > - row->body[0].iov_len = data - buf ; > - > + row->body[0].iov_len = buf - begin; > return 0; > } > -- Serge Petrenko