[Tarantool-patches] [PATCH 09/10] box/journal: journal_entry_new -- drop setting up callbacks

Cyrill Gorcunov gorcunov at gmail.com
Thu Mar 5 15:29:42 MSK 2020


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 <gorcunov at gmail.com>
---
 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



More information about the Tarantool-patches mailing list