From 2bafa51cf9e7b0ea3d6a4bbbd53796cae75249be Mon Sep 17 00:00:00 2001 From: Konstantin Osipov <kostja@tarantool.org> Date: Thu, 25 Sep 2014 01:05:34 +0400 Subject: [PATCH] Rename IPROTO_HEADER -> XROW. Drop redundant enums for IOVMAX. Better names for message encode/decode functions. --- src/box/box.cc | 6 ++-- src/box/iproto.cc | 4 +-- src/box/iproto_constants.h | 2 +- src/box/log_io.cc | 12 +++---- src/box/log_io.h | 5 ++- src/box/recovery.cc | 16 ++++----- src/box/recovery.h | 8 ++--- src/box/replica.cc | 30 ++++++++-------- src/box/replication.cc | 22 ++++++------ src/box/replication.h | 4 +-- src/box/request.h | 2 +- src/box/txn.cc | 4 +-- src/box/txn.h | 2 +- src/box/xrow.cc | 50 +++++++++++++------------- src/box/xrow.h | 74 ++++++++++++++++++-------------------- 15 files changed, 118 insertions(+), 123 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index f91207b69e..ba224d310d 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -95,7 +95,7 @@ process_ro(struct port *port, struct request *request) } static void -recover_row(void *param __attribute__((unused)), struct iproto_header *row) +recover_row(void *param __attribute__((unused)), struct xrow_header *row) { assert(row->bodycnt == 1); /* always 1 for read */ struct request request; @@ -454,8 +454,8 @@ snapshot_write_tuple(struct log_io *l, body.v_space_id = mp_bswap_u32(n); body.k_tuple = IPROTO_TUPLE; - struct iproto_header row; - memset(&row, 0, sizeof(struct iproto_header)); + struct xrow_header row; + memset(&row, 0, sizeof(struct xrow_header)); row.type = IPROTO_INSERT; row.bodycnt = 2; diff --git a/src/box/iproto.cc b/src/box/iproto.cc index 87761cbfbb..ca8b68d271 100644 --- a/src/box/iproto.cc +++ b/src/box/iproto.cc @@ -79,7 +79,7 @@ struct iproto_request struct session *session; iproto_request_f process; /* Request message code and sync. */ - struct iproto_header header; + struct xrow_header header; /* Box request, if this is a DML */ struct request request; size_t total_len; @@ -487,7 +487,7 @@ iproto_enqueue_batch(struct iproto_connection *con, struct ibuf *in) iproto_request_new(con, iproto_process_dml); IprotoRequestGuard guard(ireq); - iproto_header_decode(&ireq->header, &pos, reqend); + xrow_header_decode(&ireq->header, &pos, reqend); ireq->total_len = pos - reqstart; /* total request length */ diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h index 52f470d9ce..e89ad4fd33 100644 --- a/src/box/iproto_constants.h +++ b/src/box/iproto_constants.h @@ -81,7 +81,7 @@ enum iproto_key { bit(OFFSET) | bit(ITERATOR) | bit(KEY) | \ bit(TUPLE) | bit(FUNCTION_NAME) | bit(USER_NAME)) static inline bool -iproto_header_has_key(const char *pos, const char *end) +xrow_header_has_key(const char *pos, const char *end) { unsigned char key = pos < end ? *pos : (unsigned char) IPROTO_KEY_MAX; return key < IPROTO_KEY_MAX && IPROTO_HEAD_BMAP & (1ULL<<key); diff --git a/src/box/log_io.cc b/src/box/log_io.cc index ff6f7abffb..a55ac8303c 100644 --- a/src/box/log_io.cc +++ b/src/box/log_io.cc @@ -273,7 +273,7 @@ format_filename(struct log_dir *dir, int64_t signt, enum log_suffix suffix) /* {{{ struct log_io_cursor */ static int -row_reader(FILE *f, struct iproto_header *row) +row_reader(FILE *f, struct xrow_header *row) { const char *data; @@ -326,15 +326,15 @@ row_reader(FILE *f, struct iproto_header *row) tnt_raise(ClientError, ER_INVALID_MSGPACK, "invalid crc32"); data = bodybuf; - iproto_header_decode(row, &data, bodybuf + len); + xrow_header_decode(row, &data, bodybuf + len); return 0; } int -xlog_encode_row(const struct iproto_header *row, struct iovec *iov) +xlog_encode_row(const struct xrow_header *row, struct iovec *iov) { - int iovcnt = iproto_header_encode(row, iov + 1) + 1; + int iovcnt = xrow_header_encode(row, iov + 1) + 1; char *fixheader = (char *) region_alloc(&fiber()->gc, XLOG_FIXHEADER_SIZE); uint32_t len = 0; @@ -362,7 +362,7 @@ xlog_encode_row(const struct iproto_header *row, struct iovec *iov) iov[0].iov_base = fixheader; iov[0].iov_len = XLOG_FIXHEADER_SIZE; - assert(iovcnt <= XLOG_ROW_IOVMAX); + assert(iovcnt <= XROW_IOVMAX); return iovcnt; } @@ -400,7 +400,7 @@ log_io_cursor_close(struct log_io_cursor *i) * */ int -log_io_cursor_next(struct log_io_cursor *i, struct iproto_header *row) +log_io_cursor_next(struct log_io_cursor *i, struct xrow_header *row) { struct log_io *l = i->log; log_magic_t magic; diff --git a/src/box/log_io.h b/src/box/log_io.h index cb56cb5684..52cf559db0 100644 --- a/src/box/log_io.h +++ b/src/box/log_io.h @@ -132,10 +132,9 @@ void log_io_cursor_close(struct log_io_cursor *i); int -log_io_cursor_next(struct log_io_cursor *i, struct iproto_header *packet); +log_io_cursor_next(struct log_io_cursor *i, struct xrow_header *packet); int -xlog_encode_row(const struct iproto_header *packet, struct iovec *iov); -enum { XLOG_ROW_IOVMAX = IPROTO_PACKET_IOVMAX + 1 }; +xlog_encode_row(const struct xrow_header *packet, struct iovec *iov); typedef uint32_t log_magic_t; diff --git a/src/box/recovery.cc b/src/box/recovery.cc index b702e76a02..e022be3108 100644 --- a/src/box/recovery.cc +++ b/src/box/recovery.cc @@ -118,7 +118,7 @@ const char *wal_mode_STRS[] = { "none", "write", "fsync", NULL }; /* {{{ LSN API */ static void -fill_lsn(struct recovery_state *r, struct iproto_header *row) +fill_lsn(struct recovery_state *r, struct xrow_header *row) { if (row == NULL || row->server_id == 0) { /* Local request */ @@ -241,7 +241,7 @@ recovery_setup_panic(struct recovery_state *r, bool on_snap_error, } void -recovery_process(struct recovery_state *r, struct iproto_header *row) +recovery_process(struct recovery_state *r, struct xrow_header *row) { /* Check lsn */ int64_t current_signt = vclock_get(&r->vclock, row->server_id); @@ -328,7 +328,7 @@ recover_wal(struct recovery_state *r, struct log_io *l) log_io_cursor_open(&i, l); - struct iproto_header row; + struct xrow_header row; while (log_io_cursor_next(&i, &row) == 0) { try { recovery_process(r, &row); @@ -667,7 +667,7 @@ struct wal_write_request { /* Auxiliary. */ int64_t res; struct fiber *fiber; - struct iproto_header *row; + struct xrow_header *row; }; /* Context of the WAL writer thread. */ @@ -981,7 +981,7 @@ wal_fill_batch(struct log_io *wal, struct fio_batch *batch, int rows_per_wal, assert(max_rows > 0); fio_batch_start(batch, max_rows); - struct iovec iov[XLOG_ROW_IOVMAX]; + struct iovec iov[XROW_IOVMAX]; while (req != NULL && !fio_batch_has_space(batch, nelem(iov))) { int iovcnt = xlog_encode_row(req->row, iov); fio_batch_add(batch, iov, iovcnt); @@ -1075,7 +1075,7 @@ wal_writer_thread(void *worker_args) * to be written to disk and wait until this task is completed. */ int -wal_write(struct recovery_state *r, struct iproto_header *row) +wal_write(struct recovery_state *r, struct xrow_header *row) { /* * Bump current LSN even if wal_mode = NONE, so that @@ -1122,7 +1122,7 @@ wal_write(struct recovery_state *r, struct iproto_header *row) /* {{{ box.snapshot() */ void -snapshot_write_row(struct log_io *l, struct iproto_header *row) +snapshot_write_row(struct log_io *l, struct xrow_header *row) { static uint64_t bytes; ev_tstamp elapsed; @@ -1142,7 +1142,7 @@ snapshot_write_row(struct log_io *l, struct iproto_header *row) row->lsn = ++l->rows; row->sync = 0; /* don't write sync to wal */ - struct iovec iov[XLOG_ROW_IOVMAX]; + struct iovec iov[XROW_IOVMAX]; int iovcnt = xlog_encode_row(row, iov); /* TODO: use writev here */ diff --git a/src/box/recovery.h b/src/box/recovery.h index b509bdb122..2d6e2eba04 100644 --- a/src/box/recovery.h +++ b/src/box/recovery.h @@ -45,7 +45,7 @@ extern "C" { struct fiber; struct tbuf; -typedef void (row_handler)(void *, struct iproto_header *packet); +typedef void (row_handler)(void *, struct xrow_header *packet); typedef void (snapshot_handler)(struct log_io *); typedef void (join_handler)(const struct tt_uuid *node_uuid); @@ -116,15 +116,15 @@ void recovery_follow_local(struct recovery_state *r, ev_tstamp wal_dir_rescan_de void recovery_finalize(struct recovery_state *r); int recover_wal(struct recovery_state *r, struct log_io *l); -int wal_write(struct recovery_state *r, struct iproto_header *packet); +int wal_write(struct recovery_state *r, struct xrow_header *packet); void recovery_setup_panic(struct recovery_state *r, bool on_snap_error, bool on_wal_error); -void recovery_process(struct recovery_state *r, struct iproto_header *packet); +void recovery_process(struct recovery_state *r, struct xrow_header *packet); struct fio_batch; void -snapshot_write_row(struct log_io *l, struct iproto_header *packet); +snapshot_write_row(struct log_io *l, struct xrow_header *packet); void snapshot_save(struct recovery_state *r); #if defined(__cplusplus) diff --git a/src/box/replica.cc b/src/box/replica.cc index e06c3bae93..b31431fcd2 100644 --- a/src/box/replica.cc +++ b/src/box/replica.cc @@ -48,7 +48,7 @@ static const int RECONNECT_DELAY = 1.0; static void remote_read_row(struct ev_io *coio, struct iobuf *iobuf, - struct iproto_header *row) + struct xrow_header *row) { struct ibuf *in = &iobuf->in; @@ -72,14 +72,14 @@ remote_read_row(struct ev_io *coio, struct iobuf *iobuf, if (to_read > 0) coio_breadn(coio, in, to_read); - iproto_header_decode(row, (const char **) &in->pos, in->pos + len); + xrow_header_decode(row, (const char **) &in->pos, in->pos + len); } static void -remote_write_row(struct ev_io *coio, const struct iproto_header *row) +remote_write_row(struct ev_io *coio, const struct xrow_header *row) { - struct iovec iov[IPROTO_ROW_IOVMAX]; - int iovcnt = iproto_row_encode(row, iov); + struct iovec iov[XROW_IOVMAX]; + int iovcnt = xrow_to_iovec(row, iov); coio_writev(coio, iov, iovcnt, 0); } @@ -102,12 +102,12 @@ remote_connect(struct recovery_state *r, struct ev_io *coio, /* Authenticate */ say_debug("authenticating..."); - struct iproto_header row; - iproto_encode_auth(&row, greeting, uri->login, uri->password); + struct xrow_header row; + xrow_encode_auth(&row, greeting, uri->login, uri->password); remote_write_row(coio, &row); remote_read_row(coio, iobuf, &row); if (row.type != IPROTO_OK) - iproto_decode_error(&row); /* auth failed */ + xrow_decode_error(&row); /* auth failed */ /* auth successed */ say_info("authenticated"); @@ -152,8 +152,8 @@ replica_bootstrap(struct recovery_state *r) } /* Send JOIN request */ - struct iproto_header row; - iproto_encode_join(&row, &r->server_uuid); + struct xrow_header row; + xrow_encode_join(&row, &r->server_uuid); remote_write_row(&coio, &row); /* Add a surrogate server id for snapshot rows */ @@ -170,7 +170,7 @@ replica_bootstrap(struct recovery_state *r) /* Regular snapshot row (IPROTO_INSERT) */ recovery_process(r, &row); } else /* error or unexpected packet */ { - iproto_decode_error(&row); /* rethrow error */ + xrow_decode_error(&row); /* rethrow error */ } } @@ -178,7 +178,7 @@ replica_bootstrap(struct recovery_state *r) struct vclock vclock; vclock_create(&vclock); assert(row.type == IPROTO_OK); - iproto_decode_eos(&row, &vclock); + xrow_decode_vclock(&row, &vclock); /* Replace server vclock using data from snapshot */ vclock_copy(&r->vclock, &vclock); @@ -209,7 +209,7 @@ pull_from_remote(va_list ap) for (;;) { const char *err = NULL; try { - struct iproto_header row; + struct xrow_header row; fiber_setcancellable(true); if (! evio_is_active(&coio)) { remote_set_status(&r->remote, "connecting"); @@ -219,7 +219,7 @@ pull_from_remote(va_list ap) remote_connect(r, &coio, iobuf); /* Send SUBSCRIBE request */ err = "can't subscribe to master"; - iproto_encode_subscribe(&row, &cluster_id, + xrow_encode_subscribe(&row, &cluster_id, &r->server_uuid, &r->vclock); remote_write_row(&coio, &row); r->remote.warning_said = false; @@ -228,7 +228,7 @@ pull_from_remote(va_list ap) err = "can't read row"; remote_read_row(&coio, iobuf, &row); if (!iproto_type_is_dml(row.type)) - iproto_decode_error(&row); /* error */ + xrow_decode_error(&row); /* error */ fiber_setcancellable(false); err = NULL; diff --git a/src/box/replication.cc b/src/box/replication.cc index 666b6055a9..e9d6a4c450 100644 --- a/src/box/replication.cc +++ b/src/box/replication.cc @@ -213,11 +213,11 @@ struct replication_request { /** Replication acceptor fiber handler. */ void -replication_join(int fd, struct iproto_header *header) +replication_join(int fd, struct xrow_header *header) { assert(header->type == IPROTO_JOIN); struct tt_uuid server_uuid = uuid_nil; - iproto_decode_join(header, &server_uuid); + xrow_decode_join(header, &server_uuid); /* Notify box about new cluster server */ recovery->join_handler(&server_uuid); @@ -240,13 +240,13 @@ replication_join(int fd, struct iproto_header *header) /** Replication acceptor fiber handler. */ void -replication_subscribe(int fd, struct iproto_header *packet) +replication_subscribe(int fd, struct xrow_header *packet) { struct tt_uuid uu = uuid_nil, server_uuid = uuid_nil; struct vclock vclock; vclock_create(&vclock); - iproto_decode_subscribe(packet, &uu, &server_uuid, &vclock); + xrow_decode_subscribe(packet, &uu, &server_uuid, &vclock); /** * Check that the given UUID matches the UUID of the @@ -636,7 +636,7 @@ replication_relay_recv(ev_loop * /* loop */, struct ev_io *w, int __attribute__( /** Send a single row to the client. */ static void -replication_relay_send_row(void * /* param */, struct iproto_header *packet) +replication_relay_send_row(void * /* param */, struct xrow_header *packet) { assert(iproto_type_is_dml(packet->type)); struct recovery_state *r = recovery; @@ -644,8 +644,8 @@ replication_relay_send_row(void * /* param */, struct iproto_header *packet) /* Don't duplicate data */ if (packet->server_id == 0 || packet->server_id != r->server_id) { packet->sync = relay.sync; - struct iovec iov[IPROTO_ROW_IOVMAX]; - int iovcnt = iproto_row_encode(packet, iov); + struct iovec iov[XROW_IOVMAX]; + int iovcnt = xrow_to_iovec(packet, iov); sio_writev_all(relay.sock, iov, iovcnt); } @@ -666,11 +666,11 @@ replication_relay_join(struct recovery_state *r) recover_snap(r); /* Send response to JOIN command = end of stream */ - struct iproto_header row; - iproto_encode_eos(&row, &r->vclock); + struct xrow_header row; + xrow_encode_vclock(&row, &r->vclock); row.sync = relay.sync; - struct iovec iov[IPROTO_ROW_IOVMAX]; - int iovcnt = iproto_row_encode(&row, iov); + struct iovec iov[XROW_IOVMAX]; + int iovcnt = xrow_to_iovec(&row, iov); sio_writev_all(relay.sock, iov, iovcnt); say_info("snapshot sent"); diff --git a/src/box/replication.h b/src/box/replication.h index d6a869b9dc..c100196ddc 100644 --- a/src/box/replication.h +++ b/src/box/replication.h @@ -40,7 +40,7 @@ void replication_prefork(const char *snap_dir, const char *wal_dir); void -replication_join(int fd, struct iproto_header *packet); +replication_join(int fd, struct xrow_header *packet); /** * Subscribe a replica to updates. @@ -48,7 +48,7 @@ replication_join(int fd, struct iproto_header *packet); * @return None. On error, closes the socket. */ void -replication_subscribe(int fd, struct iproto_header *packet); +replication_subscribe(int fd, struct xrow_header *packet); #endif // TARANTOOL_REPLICATION_H_INCLUDED diff --git a/src/box/request.h b/src/box/request.h index 266004e5d6..e257109f65 100644 --- a/src/box/request.h +++ b/src/box/request.h @@ -43,7 +43,7 @@ struct request * on where this packet originated from: the write ahead * log/snapshot, client request, or a Lua request. */ - struct iproto_header *header; + struct xrow_header *header; /** * Request type - IPROTO type code */ diff --git a/src/box/txn.cc b/src/box/txn.cc index 0a9f6b6c01..7f32f24ee3 100644 --- a/src/box/txn.cc +++ b/src/box/txn.cc @@ -48,8 +48,8 @@ txn_add_redo(struct txn_stmt *stmt, struct request *request) return; /* Create a redo log row for Lua requests */ - struct iproto_header *row= (struct iproto_header *) - region_alloc0(&fiber()->gc, sizeof(struct iproto_header)); + struct xrow_header *row= (struct xrow_header *) + region_alloc0(&fiber()->gc, sizeof(struct xrow_header)); row->type = request->type; row->bodycnt = request_encode(request, row->body); stmt->row = row; diff --git a/src/box/txn.h b/src/box/txn.h index 412a90a5b3..bcf03e6459 100644 --- a/src/box/txn.h +++ b/src/box/txn.h @@ -50,7 +50,7 @@ struct txn_stmt { struct tuple *new_tuple; /** Redo info: the binary log row */ - struct iproto_header *row; + struct xrow_header *row; }; struct txn { diff --git a/src/box/xrow.cc b/src/box/xrow.cc index 221bbbe1f8..520af7243e 100644 --- a/src/box/xrow.cc +++ b/src/box/xrow.cc @@ -37,10 +37,10 @@ #include "iproto_constants.h" void -iproto_header_decode(struct iproto_header *header, const char **pos, - const char *end) +xrow_header_decode(struct xrow_header *header, const char **pos, + const char *end) { - memset(header, 0, sizeof(struct iproto_header)); + memset(header, 0, sizeof(struct xrow_header)); const char *pos2 = *pos; if (mp_check(&pos2, end) != 0) { error: @@ -91,7 +91,7 @@ iproto_header_decode(struct iproto_header *header, const char **pos, * @pre pos points at a valid msgpack */ void -iproto_decode_uuid(const char **pos, struct tt_uuid *out) +xrow_decode_uuid(const char **pos, struct tt_uuid *out) { if (mp_typeof(**pos) != MP_STR) error: @@ -104,7 +104,7 @@ iproto_decode_uuid(const char **pos, struct tt_uuid *out) } int -iproto_header_encode(const struct iproto_header *header, struct iovec *out) +xrow_header_encode(const struct xrow_header *header, struct iovec *out) { enum { HEADER_LEN_MAX = 40 }; @@ -151,22 +151,22 @@ iproto_header_encode(const struct iproto_header *header, struct iovec *out) out++; memcpy(out, header->body, sizeof(*out) * header->bodycnt); - assert(1 + header->bodycnt <= IPROTO_PACKET_IOVMAX); + assert(1 + header->bodycnt <= XROW_IOVMAX); return 1 + header->bodycnt; /* new iovcnt */ } char * -iproto_encode_uuid(char *pos, const struct tt_uuid *in) +xrow_encode_uuid(char *pos, const struct tt_uuid *in) { return mp_encode_str(pos, tt_uuid_str(in), UUID_STR_LEN); } int -iproto_row_encode(const struct iproto_header *row, - struct iovec *out) +xrow_to_iovec(const struct xrow_header *row, + struct iovec *out) { static const int iov0_len = mp_sizeof_uint(UINT32_MAX); - int iovcnt = iproto_header_encode(row, out + 1) + 1; + int iovcnt = xrow_header_encode(row, out + 1) + 1; char *fixheader = (char *) region_alloc(&fiber()->gc, iov0_len); uint32_t len = 0; for (int i = 1; i < iovcnt; i++) @@ -179,12 +179,12 @@ iproto_row_encode(const struct iproto_header *row, out[0].iov_base = fixheader; out[0].iov_len = iov0_len; - assert(iovcnt <= IPROTO_ROW_IOVMAX); + assert(iovcnt <= XROW_IOVMAX); return iovcnt; } void -iproto_encode_auth(struct iproto_header *packet, const char *greeting, +xrow_encode_auth(struct xrow_header *packet, const char *greeting, const char *login, const char *password) { memset(packet, 0, sizeof(*packet)); @@ -220,7 +220,7 @@ iproto_encode_auth(struct iproto_header *packet, const char *greeting, } void -iproto_decode_error(struct iproto_header *row) +xrow_decode_error(struct xrow_header *row) { uint32_t code = row->type & (IPROTO_TYPE_ERROR - 1); @@ -260,10 +260,10 @@ iproto_decode_error(struct iproto_header *row) } void -iproto_encode_subscribe(struct iproto_header *row, - const struct tt_uuid *cluster_uuid, - const struct tt_uuid *server_uuid, - const struct vclock *vclock) +xrow_encode_subscribe(struct xrow_header *row, + const struct tt_uuid *cluster_uuid, + const struct tt_uuid *server_uuid, + const struct vclock *vclock) { memset(row, 0, sizeof(*row)); uint32_t cluster_size = vclock_size(vclock); @@ -273,9 +273,9 @@ iproto_encode_subscribe(struct iproto_header *row, char *data = buf; data = mp_encode_map(data, 3); data = mp_encode_uint(data, IPROTO_CLUSTER_UUID); - data = iproto_encode_uuid(data, cluster_uuid); + data = xrow_encode_uuid(data, cluster_uuid); data = mp_encode_uint(data, IPROTO_SERVER_UUID); - data = iproto_encode_uuid(data, server_uuid); + data = xrow_encode_uuid(data, server_uuid); data = mp_encode_uint(data, IPROTO_VCLOCK); data = mp_encode_map(data, cluster_size); vclock_foreach(vclock, server) { @@ -290,7 +290,7 @@ iproto_encode_subscribe(struct iproto_header *row, } void -iproto_decode_subscribe(struct iproto_header *row, struct tt_uuid *cluster_uuid, +xrow_decode_subscribe(struct xrow_header *row, struct tt_uuid *cluster_uuid, struct tt_uuid *server_uuid, struct vclock *vclock) { if (row->bodycnt == 0) @@ -316,12 +316,12 @@ iproto_decode_subscribe(struct iproto_header *row, struct tt_uuid *cluster_uuid, case IPROTO_CLUSTER_UUID: if (cluster_uuid == NULL) goto skip; - iproto_decode_uuid(&d, cluster_uuid); + xrow_decode_uuid(&d, cluster_uuid); break; case IPROTO_SERVER_UUID: if (server_uuid == NULL) goto skip; - iproto_decode_uuid(&d, server_uuid); + xrow_decode_uuid(&d, server_uuid); break; case IPROTO_VCLOCK: if (vclock == NULL) @@ -358,7 +358,7 @@ iproto_decode_subscribe(struct iproto_header *row, struct tt_uuid *cluster_uuid, } void -iproto_encode_join(struct iproto_header *row, const struct tt_uuid *server_uuid) +xrow_encode_join(struct xrow_header *row, const struct tt_uuid *server_uuid) { memset(row, 0, sizeof(*row)); @@ -368,7 +368,7 @@ iproto_encode_join(struct iproto_header *row, const struct tt_uuid *server_uuid) data = mp_encode_map(data, 1); data = mp_encode_uint(data, IPROTO_SERVER_UUID); /* Greet the remote server with our server UUID */ - data = iproto_encode_uuid(data, server_uuid); + data = xrow_encode_uuid(data, server_uuid); assert(data <= buf + size); row->body[0].iov_base = buf; @@ -378,7 +378,7 @@ iproto_encode_join(struct iproto_header *row, const struct tt_uuid *server_uuid) } void -iproto_encode_eos(struct iproto_header *row, const struct vclock *vclock) +xrow_encode_vclock(struct xrow_header *row, const struct vclock *vclock) { memset(row, 0, sizeof(*row)); diff --git a/src/box/xrow.h b/src/box/xrow.h index 858c2b7e61..f1b7aa62d0 100644 --- a/src/box/xrow.h +++ b/src/box/xrow.h @@ -37,16 +37,12 @@ extern "C" { #endif enum { - IPROTO_PACKET_HEAD_IOVMAX = 1, - IPROTO_PACKET_BODY_IOVMAX = 2, - IPROTO_PACKET_IOVMAX = IPROTO_PACKET_HEAD_IOVMAX + - IPROTO_PACKET_BODY_IOVMAX + XROW_HEADER_IOVMAX = 1, + XROW_BODY_IOVMAX = 2, + XROW_IOVMAX = XROW_HEADER_IOVMAX + XROW_BODY_IOVMAX + 1 }; -enum { IPROTO_ROW_IOVMAX = IPROTO_PACKET_IOVMAX + 1 }; - - -struct iproto_header { +struct xrow_header { uint32_t type; uint32_t server_id; uint64_t sync; @@ -54,33 +50,33 @@ struct iproto_header { double tm; int bodycnt; - struct iovec body[IPROTO_PACKET_BODY_IOVMAX]; + struct iovec body[XROW_BODY_IOVMAX]; }; void -iproto_header_decode(struct iproto_header *header, - const char **pos, const char *end); +xrow_header_decode(struct xrow_header *header, + const char **pos, const char *end); struct tt_uuid; void -iproto_decode_uuid(const char **pos, struct tt_uuid *out); +xrow_decode_uuid(const char **pos, struct tt_uuid *out); char * -iproto_encode_uuid(char *pos, const struct tt_uuid *in); +xrow_encode_uuid(char *pos, const struct tt_uuid *in); int -iproto_header_encode(const struct iproto_header *header, - struct iovec *out); +xrow_header_encode(const struct xrow_header *header, + struct iovec *out); int -iproto_row_encode(const struct iproto_header *row, struct iovec *out); +xrow_to_iovec(const struct xrow_header *row, struct iovec *out); /** * \brief Decode ERROR and re-throw it as ClientError exception * \param row - */ +*/ void -iproto_decode_error(struct iproto_header *row); +xrow_decode_error(struct xrow_header *row); /** * \brief Encode AUTH command @@ -88,10 +84,10 @@ iproto_decode_error(struct iproto_header *row); * \param greeting - IPROTO greeting * \param login - user login * \param password - user password - */ +*/ void -iproto_encode_auth(struct iproto_header *row, const char *greeting, - const char *login, const char *password); +xrow_encode_auth(struct xrow_header *row, const char *greeting, + const char *login, const char *password); /** * \brief Encode SUBSCRIBE command @@ -99,12 +95,12 @@ iproto_encode_auth(struct iproto_header *row, const char *greeting, * \param cluster_uuid cluster uuid * \param server_uuid server uuid * \param vclock server vclock - */ +*/ void -iproto_encode_subscribe(struct iproto_header *row, - const struct tt_uuid *cluster_uuid, - const struct tt_uuid *server_uuid, - const struct vclock *vclock); +xrow_encode_subscribe(struct xrow_header *row, + const struct tt_uuid *cluster_uuid, + const struct tt_uuid *server_uuid, + const struct vclock *vclock); /** * \brief Decode SUBSCRIBE command @@ -112,47 +108,47 @@ iproto_encode_subscribe(struct iproto_header *row, * \param[out] cluster_uuid * \param[out] server_uuid * \param[out] vclock - */ +*/ void -iproto_decode_subscribe(struct iproto_header *row, struct tt_uuid *cluster_uuid, - struct tt_uuid *server_uuid, struct vclock *vclock); +xrow_decode_subscribe(struct xrow_header *row, struct tt_uuid *cluster_uuid, + struct tt_uuid *server_uuid, struct vclock *vclock); /** * \brief Encode JOIN command * \param[out] row * \param server_uuid - */ +*/ void -iproto_encode_join(struct iproto_header *row, const struct tt_uuid *server_uuid); +xrow_encode_join(struct xrow_header *row, const struct tt_uuid *server_uuid); /** * \brief Decode JOIN command * \param row * \param[out] server_uuid - */ +*/ static inline void -iproto_decode_join(struct iproto_header *row, struct tt_uuid *server_uuid) +xrow_decode_join(struct xrow_header *row, struct tt_uuid *server_uuid) { - return iproto_decode_subscribe(row, NULL, server_uuid, NULL); + return xrow_decode_subscribe(row, NULL, server_uuid, NULL); } /** * \brief Encode end of stream command (a response to JOIN command) * \param row[out] * \param vclock - */ +*/ void -iproto_encode_eos(struct iproto_header *row, const struct vclock *vclock); +xrow_encode_vclock(struct xrow_header *row, const struct vclock *vclock); /** * \brief Decode end of stream command (a response to JOIN command) * \param row * \param[out] vclock - */ +*/ static inline void -iproto_decode_eos(struct iproto_header *row, struct vclock *vclock) +xrow_decode_vclock(struct xrow_header *row, struct vclock *vclock) { - return iproto_decode_subscribe(row, NULL, NULL, vclock); + return xrow_decode_subscribe(row, NULL, NULL, vclock); } #if defined(__cplusplus) -- GitLab