[Tarantool-patches] [PATCH 4/5] qsync: txn_commit -- use txn flag instead of caching variable

Cyrill Gorcunov gorcunov at gmail.com
Fri Jul 10 10:56:04 MSK 2020


All over the code (including txn_libmo) we use txn_has_flag
helper, lets do the same here. There is no need for a separate
variable. It simply confuses (note though that sometimes such
trick is used to fetch current value of some variable which
might be changed externally but this is not out case we rely
on single thread here).

I also added a few empty lines to separate logical code blocks
for better readability.

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 src/box/txn.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/box/txn.c b/src/box/txn.c
index 613eb7aef..feb9a10c6 100644
--- a/src/box/txn.c
+++ b/src/box/txn.c
@@ -811,8 +811,7 @@ txn_commit(struct txn *txn)
 		return -1;
 	}
 
-	bool is_sync = txn_has_flag(txn, TXN_WAIT_SYNC);
-	if (is_sync) {
+	if (txn_has_flag(txn, TXN_WAIT_SYNC)) {
 		/*
 		 * Remote rows, if any, come before local rows, so
 		 * check for originating instance id here.
@@ -834,7 +833,7 @@ txn_commit(struct txn *txn)
 
 	fiber_set_txn(fiber(), NULL);
 	if (journal_write(req) != 0) {
-		if (is_sync)
+		if (txn_has_flag(txn, TXN_WAIT_SYNC))
 			txn_limbo_abort(&txn_limbo, limbo_entry);
 		fiber_set_txn(fiber(), txn);
 		txn_rollback(txn);
@@ -844,7 +843,8 @@ txn_commit(struct txn *txn)
 		diag_log();
 		return -1;
 	}
-	if (is_sync) {
+
+	if (txn_has_flag(txn, TXN_WAIT_SYNC)) {
 		if (txn_has_flag(txn, TXN_WAIT_ACK)) {
 			int64_t lsn = req->rows[req->n_rows - 1]->lsn;
 			txn_limbo_assign_local_lsn(&txn_limbo, limbo_entry,
@@ -857,6 +857,7 @@ txn_commit(struct txn *txn)
 			return -1;
 		}
 	}
+
 	if (!txn_has_flag(txn, TXN_IS_DONE)) {
 		txn->signature = req->res;
 		txn_complete(txn);
-- 
2.26.2



More information about the Tarantool-patches mailing list