Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: tml <tarantool-patches@dev.tarantool.org>
Subject: [Tarantool-patches] [PATCH] xrow: unify xrow_encode_confirm semantics
Date: Wed, 10 Jun 2020 15:21:16 +0300	[thread overview]
Message-ID: <20200610122116.349200-1-gorcunov@gmail.com> (raw)

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 <gorcunov@gmail.com>
---
 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

             reply	other threads:[~2020-06-10 12:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-10 12:21 Cyrill Gorcunov [this message]
2020-06-10 13:35 ` Serge Petrenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200610122116.349200-1-gorcunov@gmail.com \
    --to=gorcunov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH] xrow: unify xrow_encode_confirm semantics' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox