[Tarantool-patches] [PATCH v2 3/6] txn_limbo: introduce txn_limbo_last_synchro_entry method
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Wed Dec 23 20:25:48 MSK 2020
Thanks for the patch!
On 23.12.2020 12:59, Serge Petrenko via Tarantool-patches wrote:
> It'll be useful for box_clear_synchro_queue rework.
>
> Prerequisite #5435
> ---
> src/box/txn_limbo.c | 12 ++++++++++++
> src/box/txn_limbo.h | 7 +++++++
> 2 files changed, 19 insertions(+)
>
> diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c
> index c406ed4c8..9272f5227 100644
> --- a/src/box/txn_limbo.c
> +++ b/src/box/txn_limbo.c
> @@ -55,6 +55,18 @@ txn_limbo_is_ro(struct txn_limbo *limbo)
> return limbo->owner_id != instance_id && !txn_limbo_is_empty(limbo);
> }
>
> +struct txn_limbo_entry *
> +txn_limbo_last_synchro_entry(struct txn_limbo *limbo)
> +{
> + struct txn_limbo_entry *entry = NULL;
> + rlist_foreach_entry_reverse(entry, &limbo->queue, in_queue) {
> + if (txn_has_flag(entry->txn, TXN_WAIT_ACK))
> + break;
> + }
> + assert(entry == NULL || txn_has_flag(entry->txn, TXN_WAIT_ACK));
> + return entry;
> +}
This could be a little simpler, but up to you:
====================
@@ -58,13 +58,12 @@ txn_limbo_is_ro(struct txn_limbo *limbo)
struct txn_limbo_entry *
txn_limbo_last_synchro_entry(struct txn_limbo *limbo)
{
- struct txn_limbo_entry *entry = NULL;
+ struct txn_limbo_entry *entry;
rlist_foreach_entry_reverse(entry, &limbo->queue, in_queue) {
if (txn_has_flag(entry->txn, TXN_WAIT_ACK))
- break;
+ return entry;
}
- assert(entry == NULL || txn_has_flag(entry->txn, TXN_WAIT_ACK));
- return entry;
+ return NULL;
}
struct txn_limbo_entry *
More information about the Tarantool-patches
mailing list