From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id C1A054696C7 for ; Thu, 5 Mar 2020 15:31:41 +0300 (MSK) Received: by mail-lj1-f193.google.com with SMTP id e18so5855509ljn.12 for ; Thu, 05 Mar 2020 04:31:41 -0800 (PST) From: Cyrill Gorcunov Date: Thu, 5 Mar 2020 15:29:42 +0300 Message-Id: <20200305122943.7324-10-gorcunov@gmail.com> In-Reply-To: <20200305122943.7324-1-gorcunov@gmail.com> References: <20200305122943.7324-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 09/10] box/journal: journal_entry_new -- drop setting up callbacks List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml The callbacks gonna be different from sync and async commits thus lets untangle it from journal_entry_new interface but setup explicitly. I think setting up NULLs for entry is a safe approach so we can allow us to spend a few cycles. Signed-off-by: Cyrill Gorcunov --- src/box/journal.c | 10 +++++----- src/box/journal.h | 4 +--- src/box/txn.c | 6 +++++- src/box/vy_log.c | 3 +-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/box/journal.c b/src/box/journal.c index 11e78990d..266ee5d1f 100644 --- a/src/box/journal.c +++ b/src/box/journal.c @@ -53,9 +53,7 @@ static struct journal dummy_journal = { struct journal *current_journal = &dummy_journal; struct journal_entry * -journal_entry_new(size_t n_rows, struct region *region, - journal_entry_complete_cb on_complete_cb, - void *on_complete_cb_data) +journal_entry_new(size_t n_rows, struct region *region) { struct journal_entry *entry; @@ -68,11 +66,13 @@ journal_entry_new(size_t n_rows, struct region *region, diag_set(OutOfMemory, size, "region", "struct journal_entry"); return NULL; } + entry->approx_len = 0; entry->n_rows = n_rows; entry->res = -1; - entry->on_complete_cb = on_complete_cb; - entry->on_complete_cb_data = on_complete_cb_data; + entry->on_complete_cb = NULL; + entry->on_complete_cb_data = NULL; + return entry; } diff --git a/src/box/journal.h b/src/box/journal.h index 64f167c6f..e74c69910 100644 --- a/src/box/journal.h +++ b/src/box/journal.h @@ -93,9 +93,7 @@ struct region; * @return NULL if out of memory, fiber diagnostics area is set */ struct journal_entry * -journal_entry_new(size_t n_rows, struct region *region, - journal_entry_complete_cb on_complete_cb, - void *on_complete_cb_data); +journal_entry_new(size_t n_rows, struct region *region); /** * Finalize a single entry. diff --git a/src/box/txn.c b/src/box/txn.c index 685f476e2..613da181b 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -487,7 +487,7 @@ txn_journal_entry_new(struct txn *txn) assert(txn->n_new_rows + txn->n_applier_rows > 0); req = journal_entry_new(txn->n_new_rows + txn->n_applier_rows, - &txn->region, txn_entry_complete_cb, txn); + &txn->region); if (req == NULL) return NULL; @@ -614,6 +614,8 @@ txn_commit_async(struct txn *txn) txn_rollback(txn); return -1; } + req->on_complete_cb = txn_entry_complete_cb; + req->on_complete_cb_data = txn; return txn_write_to_wal(req); } @@ -641,6 +643,8 @@ txn_commit(struct txn *txn) txn_rollback(txn); goto out; } + req->on_complete_cb = txn_entry_complete_cb; + req->on_complete_cb_data = txn; if (txn_write_to_wal(req) != 0) return -1; diff --git a/src/box/vy_log.c b/src/box/vy_log.c index cb291f3c8..276c5303e 100644 --- a/src/box/vy_log.c +++ b/src/box/vy_log.c @@ -815,8 +815,7 @@ vy_log_tx_flush(struct vy_log_tx *tx) tx_size++; size_t used = region_used(&fiber()->gc); - struct journal_entry *entry = journal_entry_new(tx_size, &fiber()->gc, - NULL, NULL); + struct journal_entry *entry = journal_entry_new(tx_size, &fiber()->gc); if (entry == NULL) goto err; -- 2.20.1