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 05D3C445320 for ; Fri, 10 Jul 2020 10:56:59 +0300 (MSK) Received: by mail-lj1-f193.google.com with SMTP id d17so5402381ljl.3 for ; Fri, 10 Jul 2020 00:56:59 -0700 (PDT) From: Cyrill Gorcunov Date: Fri, 10 Jul 2020 10:56:04 +0300 Message-Id: <20200710075605.217824-5-gorcunov@gmail.com> In-Reply-To: <20200710075605.217824-1-gorcunov@gmail.com> References: <20200710075605.217824-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 4/5] qsync: txn_commit -- use txn flag instead of caching variable List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Cc: Vladislav Shpilevoy 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 --- 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