/* 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 */
/*
* 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);
+ }
}
/*
{
int ret = 0;
void *status;
+ struct lttng_consumer_local_data *tmp_ctx;
/* Parse arguments */
progname = argv[0];
}
/* Init */
- lttng_consumer_init();
+ if (lttng_consumer_init() < 0) {
+ goto error;
+ }
+
/* Init socket timeouts */
lttcomm_init();
lttcomm_inet_init();
ctx->type = opt_type;
- /* Initialize communication library */
- lttcomm_init();
-
ret = utils_create_pipe(health_quit_pipe);
if (ret < 0) {
goto error_health_pipe;
* sessiond thread reply to the sessiond that we are ready.
*/
while (uatomic_read(<tng_consumer_ready)) {
- sleep(1);
+ usleep(100000);
}
cmm_smp_mb(); /* Read ready before following operations */
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;
}