X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=ltt-sessiond%2Ffutex.c;h=de3f94e6e6a0bb6dcbc25505721ad033c398a1c1;hp=0c333fce68e5fef0d2d881ef2b19435ccea6c48b;hb=0fdd1e2c4a9f725daed3f91dd4f5609ae54ebe93;hpb=0177d773712c6d6b11e395708ae2cc686d6917a4 diff --git a/ltt-sessiond/futex.c b/ltt-sessiond/futex.c index 0c333fce6..de3f94e6e 100644 --- a/ltt-sessiond/futex.c +++ b/ltt-sessiond/futex.c @@ -18,6 +18,7 @@ */ #define _GNU_SOURCE +#include #include #include #include @@ -43,6 +44,25 @@ * Ref: git://git.lttng.org/userspace-rcu.git */ +/* + * Update futex according to active or not. This scheme is used to wake every + * libust waiting on the shared memory map futex hence the INT_MAX used in the + * futex() call. If active, we set the value and wake everyone else we indicate + * that we are gone (cleanup() case). + */ +void futex_wait_update(int32_t *futex, int active) +{ + if (active) { + uatomic_set(futex, 1); + futex_async(futex, FUTEX_WAKE, + INT_MAX, NULL, NULL, 0); + } else { + uatomic_set(futex, 0); + } + + DBG("Futex wait update active %d", active); +} + /* * Prepare futex. */