From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 4061F469710 for ; Wed, 10 Jun 2020 15:21:20 +0300 (MSK) Received: by mail-lf1-f66.google.com with SMTP id c21so1335869lfb.3 for ; Wed, 10 Jun 2020 05:21:20 -0700 (PDT) From: Cyrill Gorcunov Date: Wed, 10 Jun 2020 15:21:16 +0300 Message-Id: <20200610122116.349200-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [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: tml 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 -- 2.26.2