Fix: consumer signal handling race
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 5 Sep 2015 23:58:29 +0000 (19:58 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 24 Sep 2015 04:35:35 +0000 (00:35 -0400)
If a signal comes in after ctx has been destroyed, it will try to use a
closed file descriptor.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-consumerd/lttng-consumerd.c

index c75a80138729e0f3e13c723ca17f959426718b01..65ee16d83cba3eb8198592f5f16f8c547f96a34e 100644 (file)
@@ -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);
This page took 0.025985 seconds and 4 git commands to generate.