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>
Sun, 6 Sep 2015 03:07:11 +0000 (23:07 -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
src/bin/lttng-sessiond/main.c

index 764cf4cb0f59ff981629c99078b31676d0f700b2..0d34feeb342904ddc599c84fbc7c7359ade16872 100644 (file)
@@ -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) {
index 2983cbf8c1da67dbed1c2092db68b3631532cb24..7c48e4da40b2955156d36a0511e2e7f2b35e137f 100644 (file)
@@ -712,7 +712,6 @@ static void sessiond_cleanup(void)
        wait_consumer(&ustconsumer64_data);
        wait_consumer(&ustconsumer32_data);
 
-
        DBG("Cleaning up all agent apps");
        agent_app_ht_clean();
 
This page took 0.028879 seconds and 5 git commands to generate.