From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 703744696C3 for ; Wed, 22 Apr 2020 22:57:06 +0300 (MSK) Received: by mail-lj1-f194.google.com with SMTP id f18so3677350lja.13 for ; Wed, 22 Apr 2020 12:57:06 -0700 (PDT) From: Cyrill Gorcunov Date: Wed, 22 Apr 2020 22:56:58 +0300 Message-Id: <20200422195658.14170-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH] cbus: fix inconsistency in endpoint creation List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml The notification of wait variable shall be done under a bound mutex locked. Otherwise the results are not guaranteed (see pthread manuals). Thus when we create a new endpoint via cbus_endpoint_create and there is an other thread which sleeps inside cpipe_create we should notify the sleeper under cbus.mutex. Fixes #4806 Reported-by: Alexander Turenko Signed-off-by: Cyrill Gorcunov --- issue https://github.com/tarantool/tarantool/issues/4806 branch gorcunov/gh-4806-cpipe-mutex The fix is done on top of 1.10 series but 2.x series should be fixed as well. src/cbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cbus.c b/src/cbus.c index 314d7dc42..28164f666 100644 --- a/src/cbus.c +++ b/src/cbus.c @@ -234,7 +234,6 @@ cbus_endpoint_create(struct cbus_endpoint *endpoint, const char *name, ev_async_start(endpoint->consumer, &endpoint->async); rlist_add_tail(&cbus.endpoints, &endpoint->in_cbus); - tt_pthread_mutex_unlock(&cbus.mutex); /* * Alert all waiting producers. * @@ -243,6 +242,7 @@ cbus_endpoint_create(struct cbus_endpoint *endpoint, const char *name, * blocked on cond. */ tt_pthread_cond_broadcast(&cbus.cond); + tt_pthread_mutex_unlock(&cbus.mutex); return 0; } -- 2.20.1