From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id CD4002E2C6 for ; Sun, 9 Jun 2019 16:44:56 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3P68PCBPK87l for ; Sun, 9 Jun 2019 16:44:56 -0400 (EDT) Received: from smtp39.i.mail.ru (smtp39.i.mail.ru [94.100.177.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 8587E2E26D for ; Sun, 9 Jun 2019 16:44:56 -0400 (EDT) From: Georgy Kirichenko Subject: [tarantool-patches] [PATCH v3 10/14] core: latch_unlock_external routine Date: Sun, 9 Jun 2019 23:44:39 +0300 Message-Id: <98f0889a17245be64f1753012419e92c7ceef4e7.1560112747.git.georgy@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Georgy Kirichenko 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