[Tarantool-patches] [PATCH] xrow: unify xrow_encode_confirm semantics
Serge Petrenko
sergepetrenko at tarantool.org
Wed Jun 10 16:35:34 MSK 2020
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 <gorcunov at 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
Thanks! I applied your patch and pushed the patchset on a new branch, as
decided.
new branch gh-4842-sync-replication
--
Serge Petrenko
More information about the Tarantool-patches
mailing list