From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 49A6F4765E3 for ; Wed, 23 Dec 2020 20:25:50 +0300 (MSK) References: From: Vladislav Shpilevoy Message-ID: Date: Wed, 23 Dec 2020 18:25:48 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Serge Petrenko , gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org 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 *