From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp56.i.mail.ru (smtp56.i.mail.ru [217.69.128.36]) (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 B44604765E1 for ; Wed, 23 Dec 2020 14:59:46 +0300 (MSK) From: Serge Petrenko Date: Wed, 23 Dec 2020 14:59:21 +0300 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [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: v.shpilevoy@tarantool.org, gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org 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; +} + struct txn_limbo_entry * txn_limbo_append(struct txn_limbo *limbo, uint32_t id, struct txn *txn) { diff --git a/src/box/txn_limbo.h b/src/box/txn_limbo.h index f7d67a826..a49356c14 100644 --- a/src/box/txn_limbo.h +++ b/src/box/txn_limbo.h @@ -189,6 +189,13 @@ txn_limbo_last_entry(struct txn_limbo *limbo) in_queue); } +/** + * Return the last synchronous transaction in the limbo or NULL when it is + * empty. + */ +struct txn_limbo_entry * +txn_limbo_last_synchro_entry(struct txn_limbo *limbo); + /** * Allocate, create, and append a new transaction to the limbo. * The limbo entry is allocated on the transaction's region. -- 2.24.3 (Apple Git-128)