Typo: catched -> caught
[lttng-tools.git] / src / bin / lttng-consumerd / lttng-consumerd.c
index 4a9a7a4929200bfd53c838eed13b48f52dd0ae50..55a3e6ea7cea67bb5f2e3f22b0617e910e1687b7 100644 (file)
@@ -65,6 +65,8 @@ static int sigintcount = 0;
 /* Argument variables */
 int lttng_opt_quiet;    /* not static in error.h */
 int lttng_opt_verbose;  /* not static in error.h */
+int lttng_opt_mi;       /* not static in error.h */
+
 static int opt_daemon;
 static const char *progname;
 static char command_sock_path[PATH_MAX]; /* Global command socket path */
@@ -101,13 +103,15 @@ static void sighandler(int sig)
 
        /*
         * Ignore SIGPIPE because it should not stop the consumer whenever a
-        * SIGPIPE is catched through a FD operation.
+        * SIGPIPE is caught through a FD operation.
         */
        if (sig == SIGPIPE) {
                return;
        }
 
-       lttng_consumer_should_exit(ctx);
+       if (ctx) {
+               lttng_consumer_should_exit(ctx);
+       }
 }
 
 /*
@@ -288,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];
@@ -341,7 +346,10 @@ int main(int argc, char **argv)
        }
 
        /* Init */
-       lttng_consumer_init();
+       if (lttng_consumer_init() < 0) {
+               goto error;
+       }
+
        /* Init socket timeouts */
        lttcomm_init();
        lttcomm_inet_init();
@@ -405,9 +413,6 @@ int main(int argc, char **argv)
 
        ctx->type = opt_type;
 
-       /* Initialize communication library */
-       lttcomm_init();
-
        ret = utils_create_pipe(health_quit_pipe);
        if (ret < 0) {
                goto error_health_pipe;
@@ -426,7 +431,7 @@ int main(int argc, char **argv)
         * sessiond thread reply to the sessiond that we are ready.
         */
        while (uatomic_read(&lttng_consumer_ready)) {
-               sleep(1);
+               usleep(100000);
        }
        cmm_smp_mb();   /* Read ready before following operations */
 
@@ -520,22 +525,23 @@ health_error:
 error_health_pipe:
        if (!ret) {
                ret = EXIT_SUCCESS;
-               lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_EXIT_SUCCESS);
                goto end;
        }
 
 error:
        ret = EXIT_FAILURE;
-       if (ctx) {
-               lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_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);
        }
 
+       /* Ensure all prior call_rcu are done. */
+       rcu_barrier();
        return ret;
 }
This page took 0.02604 seconds and 4 git commands to generate.