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>
Tue, 8 Sep 2015 13:43:42 +0000 (09:43 -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 00da2e46ef69ef3046f11a2b6a9c160c5439c56b..9519eb397d789c89350085bbb5bcb550077cf94f 100644 (file)
@@ -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();
 
This page took 0.028823 seconds and 4 git commands to generate.