From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Cyrill Gorcunov <gorcunov@gmail.com>,
tml <tarantool-patches@dev.tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH 4/5] qsync: txn_commit -- use txn flag instead of caching variable
Date: Fri, 10 Jul 2020 22:36:32 +0200 [thread overview]
Message-ID: <804b33af-ddea-aefa-b69f-5615831967e7@tarantool.org> (raw)
In-Reply-To: <20200710075605.217824-5-gorcunov@gmail.com>
On 10/07/2020 09:56, Cyrill Gorcunov wrote:
> 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@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);
>
next prev parent reply other threads:[~2020-07-10 20:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-10 7:56 [Tarantool-patches] [PATCH 0/5] qsync: code cleanup Cyrill Gorcunov
2020-07-10 7:56 ` [Tarantool-patches] [PATCH 1/5] qsync: eliminate redundant writes Cyrill Gorcunov
2020-07-10 20:31 ` Vladislav Shpilevoy
2020-07-10 21:04 ` Cyrill Gorcunov
2020-07-10 7:56 ` [Tarantool-patches] [PATCH 2/5] qsync: add a comment about sync txn in journal allocation Cyrill Gorcunov
2020-07-10 20:33 ` Vladislav Shpilevoy
2020-07-10 20:34 ` Vladislav Shpilevoy
2020-07-10 21:07 ` Cyrill Gorcunov
2020-07-10 21:08 ` Vladislav Shpilevoy
2020-07-11 16:08 ` Vladislav Shpilevoy
2020-07-10 7:56 ` [Tarantool-patches] [PATCH 3/5] qsync: txn_commit_async -- drop redundant variable Cyrill Gorcunov
2020-07-10 20:35 ` Vladislav Shpilevoy
2020-07-10 21:10 ` Cyrill Gorcunov
2020-07-10 21:28 ` Vladislav Shpilevoy
2020-07-10 21:36 ` Cyrill Gorcunov
2020-07-11 14:10 ` Vladislav Shpilevoy
2020-07-11 15:18 ` Cyrill Gorcunov
2020-07-10 7:56 ` [Tarantool-patches] [PATCH 4/5] qsync: txn_commit -- use txn flag instead of caching variable Cyrill Gorcunov
2020-07-10 20:36 ` Vladislav Shpilevoy [this message]
2020-07-10 21:27 ` Cyrill Gorcunov
2020-07-10 7:56 ` [Tarantool-patches] [PATCH 5/5] qsync: sanitize txn_limbo_on_rollback Cyrill Gorcunov
2020-07-10 20:38 ` Vladislav Shpilevoy
2020-07-11 15:46 ` Cyrill Gorcunov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=804b33af-ddea-aefa-b69f-5615831967e7@tarantool.org \
--to=v.shpilevoy@tarantool.org \
--cc=gorcunov@gmail.com \
--cc=tarantool-patches@dev.tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 4/5] qsync: txn_commit -- use txn flag instead of caching variable' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox