[Tarantool-patches] [PATCH v2 3/6] txn_limbo: introduce txn_limbo_last_synchro_entry method
Serge Petrenko
sergepetrenko at tarantool.org
Wed Dec 23 14:59:21 MSK 2020
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)
More information about the Tarantool-patches
mailing list