From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH 11/13] xrow: factor out helper for setting REPLACE request body Date: Sat, 10 Aug 2019 13:03:38 +0300 Message-Id: <6f238cb25951e28d9ef5d97b0d6f4687dba72625.1565430177.git.vdavydov.dev@gmail.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: tarantool-patches@freelists.org List-ID: We will reuse it to relay a snapshot to a newly joined replica. --- src/box/iproto_constants.h | 11 +++++++++++ src/box/memtx_engine.c | 6 +----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h index 126d7335..724cce53 100644 --- a/src/box/iproto_constants.h +++ b/src/box/iproto_constants.h @@ -343,6 +343,17 @@ struct PACKED request_replace_body { uint8_t k_tuple; }; +static inline void +request_replace_body_create(struct request_replace_body *body, + uint32_t space_id) +{ + body->m_body = 0x82; /* map of two elements. */ + body->k_space_id = IPROTO_SPACE_ID; + body->m_space_id = 0xce; /* uint32 */ + body->v_space_id = mp_bswap_u32(space_id); + body->k_tuple = IPROTO_TUPLE; +} + /** * Xrow keys for Vinyl run information. * @sa struct vy_run_info. diff --git a/src/box/memtx_engine.c b/src/box/memtx_engine.c index c92ed82b..ea197cad 100644 --- a/src/box/memtx_engine.c +++ b/src/box/memtx_engine.c @@ -432,11 +432,7 @@ checkpoint_write_tuple(struct xlog *l, uint32_t space_id, uint32_t group_id, const char *data, uint32_t size) { struct request_replace_body body; - body.m_body = 0x82; /* map of two elements. */ - body.k_space_id = IPROTO_SPACE_ID; - body.m_space_id = 0xce; /* uint32 */ - body.v_space_id = mp_bswap_u32(space_id); - body.k_tuple = IPROTO_TUPLE; + request_replace_body_create(&body, space_id); struct xrow_header row; memset(&row, 0, sizeof(struct xrow_header)); -- 2.20.1