[Tarantool-patches] [PATCH] cbus: fix inconsistency in endpoint creation
Cyrill Gorcunov
gorcunov at gmail.com
Wed Apr 22 22:56:58 MSK 2020
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 at tarantool.org>
Signed-off-by: Cyrill Gorcunov <gorcunov at 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
More information about the Tarantool-patches
mailing list