From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp29.i.mail.ru (smtp29.i.mail.ru [94.100.177.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 4E1EB4765E0 for ; Thu, 24 Dec 2020 19:13:29 +0300 (MSK) References: From: Serge Petrenko Message-ID: <4e75e345-0d72-d950-ef63-f69344a8c00f@tarantool.org> Date: Thu, 24 Dec 2020 19:13:28 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [Tarantool-patches] [PATCH v2 3/6] txn_limbo: introduce txn_limbo_last_synchro_entry method List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy , gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org 23.12.2020 20:25, Vladislav Shpilevoy пишет: > 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 * Nice. Applied. -- Serge Petrenko