From: Mathieu Desnoyers Date: Sat, 5 Sep 2015 23:58:29 +0000 (-0400) Subject: Fix: consumer signal handling race X-Git-Tag: v2.6.1~21 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=0f85bec52aea64abfd89616b00115c91fd2171b3;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 c75a80138..65ee16d83 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); + } } /* @@ -290,6 +292,7 @@ int main(int argc, char **argv) { int ret = 0; void *status; + struct lttng_consumer_local_data *tmp_ctx; /* Parse arguments */ progname = argv[0]; @@ -529,7 +532,10 @@ error: ret = EXIT_FAILURE; end: - 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) { health_app_destroy(health_consumerd);