From: Mathieu Desnoyers Date: Mon, 29 Aug 2011 22:49:25 +0000 (-0400) Subject: Implement futex wait scheme X-Git-Tag: v1.9.1~213 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=80e2814bbd91e86984f24a74cc75f9cc4aaa6824;p=lttng-ust.git Implement futex wait scheme Signed-off-by: Mathieu Desnoyers --- diff --git a/libust/lttng-ust-comm.c b/libust/lttng-ust-comm.c index 93f48940..a5f2b0b0 100644 --- a/libust/lttng-ust-comm.c +++ b/libust/lttng-ust-comm.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#define _LGPL_SOURCE #include #include #include @@ -35,6 +36,7 @@ #include #include #include +#include #include #include @@ -477,6 +479,8 @@ error: static void wait_for_sessiond(struct sock_info *sock_info) { + int ret; + ust_lock(); if (lttng_ust_comm_should_quit) { goto quit; @@ -489,9 +493,19 @@ void wait_for_sessiond(struct sock_info *sock_info) ust_unlock(); DBG("Waiting for %s apps sessiond", sock_info->name); - /* Wait for futex wakeup TODO */ - sleep(5); - + /* Wait for futex wakeup */ + if (uatomic_read((int32_t *) sock_info->wait_shm_mmap) == 0) { + ret = futex_async((int32_t *) sock_info->wait_shm_mmap, + FUTEX_WAIT, 0, NULL, NULL, 0); + /* + * FIXME: Currently, futexes on read-only shm seems to + * EFAULT. + */ + if (ret < 0) { + PERROR("futex"); + sleep(5); + } + } return; quit: