From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp29.i.mail.ru (smtp29.i.mail.ru [94.100.177.89]) (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 9F36B42F4AD for ; Wed, 10 Jun 2020 16:35:35 +0300 (MSK) References: <20200610122116.349200-1-gorcunov@gmail.com> From: Serge Petrenko Message-ID: <104550ab-3d34-7cd0-09d0-729078cdba3e@tarantool.org> Date: Wed, 10 Jun 2020 16:35:34 +0300 MIME-Version: 1.0 In-Reply-To: <20200610122116.349200-1-gorcunov@gmail.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [Tarantool-patches] [PATCH] xrow: unify xrow_encode_confirm semantics List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov , tml 10.06.2020 15:21, Cyrill Gorcunov пишет: > We already have similar routine xrow_encode_auth > which fills up the header from scratch and returns > nonzero code on error. Lets make here the same. > > Signed-off-by: Cyrill Gorcunov > --- > src/box/txn_limbo.c | 11 +++++------ > src/box/xrow.c | 5 ++++- > 2 files changed, 9 insertions(+), 7 deletions(-) > > diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c > index 896078db4..a61ab1f5f 100644 > --- a/src/box/txn_limbo.c > +++ b/src/box/txn_limbo.c > @@ -142,13 +142,12 @@ txn_limbo_wait_complete(struct txn_limbo *limbo, struct txn_limbo_entry *entry) > static int > txn_limbo_write_confirm(struct txn_limbo *limbo, struct txn_limbo_entry *entry) > { > - /* Prepare a confirm entry. */ > - struct xrow_header row = {0}; > - struct request request = {0}; > - request.header = &row; > + struct xrow_header row; > + struct request request = { > + .header = &row, > + }; > > - row.bodycnt = xrow_encode_confirm(&row, limbo->instance_id, entry->lsn); > - if (row.bodycnt < 0) > + if (xrow_encode_confirm(&row, limbo->instance_id, entry->lsn) < 0) > return -1; > > struct txn *txn = txn_begin(); > diff --git a/src/box/xrow.c b/src/box/xrow.c > index f197e0d85..2acc19ec5 100644 > --- a/src/box/xrow.c > +++ b/src/box/xrow.c > @@ -897,12 +897,15 @@ xrow_encode_confirm(struct xrow_header *row, uint32_t replica_id, int64_t lsn) > pos = mp_encode_uint(pos, IPROTO_LSN); > pos = mp_encode_uint(pos, lsn); > > + memset(row, 0, sizeof(*row)); > + > row->body[0].iov_base = buf; > row->body[0].iov_len = len; > + row->bodycnt = 1; > > row->type = IPROTO_CONFIRM; > > - return 1; > + return 0; > } > > int Thanks! I applied your patch and pushed the patchset on a new branch, as decided. new branch gh-4842-sync-replication -- Serge Petrenko