From: Mathieu Desnoyers Date: Sat, 5 Sep 2015 23:58:29 +0000 (-0400) Subject: Fix: consumer signal handling race X-Git-Tag: v2.7.0-rc2~60 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=a04821e0fb5919edd3130dc56dc14bd2ca3b6ee4;p=lttng-tools.git Fix: consumer signal handling race If a signal comes in after ctx has been destroyed, it will try to use a closed file descriptor. Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c index 764cf4cb0..0d34feeb3 100644 --- a/src/bin/lttng-consumerd/lttng-consumerd.c +++ b/src/bin/lttng-consumerd/lttng-consumerd.c @@ -109,7 +109,9 @@ static void sighandler(int sig) return; } - lttng_consumer_should_exit(ctx); + if (ctx) { + lttng_consumer_should_exit(ctx); + } } /* @@ -312,6 +314,7 @@ int main(int argc, char **argv) { int ret = 0, retval = 0; void *status; + struct lttng_consumer_local_data *tmp_ctx; if (set_signal_handler()) { retval = -1; @@ -626,7 +629,10 @@ exit_health_thread: exit_health_pipe: exit_init_data: - lttng_consumer_destroy(ctx); + tmp_ctx = ctx; + ctx = NULL; + cmm_barrier(); /* Clear ctx for signal handler. */ + lttng_consumer_destroy(tmp_ctx); lttng_consumer_cleanup(); if (health_consumerd) { diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 00da2e46e..9519eb397 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -708,7 +708,6 @@ static void sessiond_cleanup(void) wait_consumer(&ustconsumer64_data); wait_consumer(&ustconsumer32_data); - DBG("Cleaning up all agent apps"); agent_app_ht_clean();