From 26c9d55e1367d3aff6e501b5a1295edd1ccbc210 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 23 Jul 2012 11:31:34 -0400 Subject: [PATCH 1/1] Fix: relayd and sessiond: dispatch thread exit is shared across threads Signed-off-by: Mathieu Desnoyers --- src/bin/lttng-relayd/main.c | 5 +++-- src/bin/lttng-sessiond/main.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 0428d33ce..81f10b783 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -74,6 +74,7 @@ static int thread_quit_pipe[2] = { -1, -1 }; */ static int relay_cmd_pipe[2] = { -1, -1 }; +/* Shared between threads */ static int dispatch_thread_exit; static pthread_t listener_thread; @@ -272,7 +273,7 @@ void stop_threads(void) } /* Dispatch thread */ - dispatch_thread_exit = 1; + CMM_STORE_SHARED(dispatch_thread_exit, 1); futex_nto1_wake(&relay_cmd_queue.futex); } @@ -608,7 +609,7 @@ void *relay_thread_dispatcher(void *data) DBG("[thread] Relay dispatcher started"); - while (!dispatch_thread_exit) { + while (!CMM_LOAD_SHARED(dispatch_thread_exit)) { /* Atomically prepare the queue futex */ futex_nto1_prepare(&relay_cmd_queue.futex); diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 85b960ee3..5664b0be1 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -103,6 +103,7 @@ static struct consumer_data ustconsumer32_data = { .cmd_sock = -1, }; +/* Shared between threads */ static int dispatch_thread_exit; /* Global application Unix socket path */ @@ -420,7 +421,7 @@ static void stop_threads(void) } /* Dispatch thread */ - dispatch_thread_exit = 1; + CMM_STORE_SHARED(dispatch_thread_exit, 1); futex_nto1_wake(&ust_cmd_queue.futex); } @@ -1219,7 +1220,7 @@ static void *thread_dispatch_ust_registration(void *data) DBG("[thread] Dispatch UST command started"); - while (!dispatch_thread_exit) { + while (!CMM_LOAD_SHARED(dispatch_thread_exit)) { /* Atomically prepare the queue futex */ futex_nto1_prepare(&ust_cmd_queue.futex); -- 2.34.1