Fix: thread exit vs futex wait/wakeup race
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 17 May 2017 22:36:54 +0000 (18:36 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 19 May 2017 14:23:58 +0000 (10:23 -0400)
commit0ed3b1a8426260c2b8a9cb7987b6b242568a2d02
treed4e059ca5249a77b96ff98f5f2f5a770feb39c89
parent8ada111f6d3ab40d1c33cf1a7b2546de9a47d1d5
Fix: thread exit vs futex wait/wakeup race

relayd_live_stop performs, in this order:

        CMM_STORE_SHARED(live_dispatch_thread_exit, 1);   [A]
        futex_nto1_wake(&viewer_conn_queue.futex);        [B]

whereas thread_dispatcher does:

   while (!CMM_LOAD_SHARED(live_dispatch_thread_exit)) {  [1]

     [...]
     futex_nto1_prepare(&viewer_conn_queue.futex);        [2]
     [...]
     futex_nto1_wait(&viewer_conn_queue.futex);           [3]

Unfortunately, on the following sequence:

[1] [A] [B] [2] [3]

thread_dispatcher will end up hanging.

We need to move the live_dispatch_thread_exit load between "prepare" and
"wait" to fix this.

There are similar scenarios with relay_thread_dispatcher, and the
session daemon thread_dispatch_ust_registration, which are also fixed
here.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-relayd/live.c
src/bin/lttng-relayd/main.c
src/bin/lttng-sessiond/main.c
This page took 0.025558 seconds and 4 git commands to generate.