From: Cyrill Gorcunov <gorcunov@gmail.com> To: tml <tarantool-patches@dev.tarantool.org> Subject: [Tarantool-patches] [PATCH] cbus: fix inconsistency in endpoint creation Date: Wed, 22 Apr 2020 22:56:58 +0300 [thread overview] Message-ID: <20200422195658.14170-1-gorcunov@gmail.com> (raw) 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 <alexander.turenko@tarantool.org> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> --- 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
next reply other threads:[~2020-04-22 19:57 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-22 19:56 Cyrill Gorcunov [this message] 2020-04-24 7:57 ` Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200422195658.14170-1-gorcunov@gmail.com \ --to=gorcunov@gmail.com \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH] cbus: fix inconsistency in endpoint creation' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox