[tarantool-patches] [PATCH v3 10/14] core: latch_unlock_external routine

Georgy Kirichenko georgy at tarantool.org
Sun Jun 9 23:44:39 MSK 2019


Allow unlock a latch from a fiber which isn't owner of the latch. This
is required to process transaction triggers asynchronously.

Prerequisites: #1254
---
 src/box/alter.cc     |  2 +-
 src/lib/core/latch.h | 13 +++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/box/alter.cc b/src/box/alter.cc
index 671209b51..adf30c9b6 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -3446,7 +3446,7 @@ unlock_after_dd(struct trigger *trigger, void *event)
 {
 	(void) trigger;
 	(void) event;
-	latch_unlock(&schema_lock);
+	latch_unlock_external(&schema_lock);
 }
 
 static void
diff --git a/src/lib/core/latch.h b/src/lib/core/latch.h
index 49c59cf63..b27d6dd08 100644
--- a/src/lib/core/latch.h
+++ b/src/lib/core/latch.h
@@ -159,9 +159,8 @@ latch_trylock(struct latch *l)
  * \copydoc box_latch_unlock
  */
 static inline void
-latch_unlock(struct latch *l)
+latch_unlock_external(struct latch *l)
 {
-	assert(l->owner == fiber());
 	l->owner = NULL;
 	if (!rlist_empty(&l->queue)) {
 		struct fiber *f = rlist_first_entry(&l->queue,
@@ -176,6 +175,16 @@ latch_unlock(struct latch *l)
 	}
 }
 
+/**
+ * \copydoc box_latch_unlock
+ */
+static inline void
+latch_unlock(struct latch *l)
+{
+	assert(l->owner == fiber());
+	latch_unlock_external(l);
+}
+
 /** \cond public */
 
 /**
-- 
2.21.0





More information about the Tarantool-patches mailing list