Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH] xrow: unify xrow_encode_confirm semantics
@ 2020-06-10 12:21 Cyrill Gorcunov
  2020-06-10 13:35 ` Serge Petrenko
  0 siblings, 1 reply; 2+ messages in thread
From: Cyrill Gorcunov @ 2020-06-10 12:21 UTC (permalink / raw)
  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 <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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-10 13:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-10 12:21 [Tarantool-patches] [PATCH] xrow: unify xrow_encode_confirm semantics Cyrill Gorcunov
2020-06-10 13:35 ` Serge Petrenko

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