X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-consumerd%2Flttng-consumerd.c;h=1cc1eb9ae567c5a957bbf4d0704a2805337050f8;hb=22dad56815ce0201c5ae7d5ef5d79cc0c6a42c5e;hp=626fbb73a1fe960b1cdfc03fc44789c46442e8e6;hpb=e8fa9fb0539ec3d734f6d0ab91220b4538b2ea30;p=lttng-tools.git diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c index 626fbb73a..1cc1eb9ae 100644 --- a/src/bin/lttng-consumerd/lttng-consumerd.c +++ b/src/bin/lttng-consumerd/lttng-consumerd.c @@ -16,7 +16,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE #define _LGPL_SOURCE #include #include @@ -38,14 +37,13 @@ #include #include #include -#include #include #include #include #include -#include -#include +#include +#include #include #include #include @@ -103,13 +101,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); + } } /* @@ -312,6 +312,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; @@ -361,12 +362,6 @@ int main(int argc, char **argv) goto exit_health_consumerd_cleanup; } - /* Set up max poll set size */ - if (lttng_poll_set_max_size()) { - retval = -1; - goto exit_init_data; - } - if (*command_sock_path == '\0') { switch (opt_type) { case LTTNG_CONSUMER_KERNEL: @@ -419,6 +414,10 @@ int main(int argc, char **argv) set_ulimit(); } + if (run_as_create_worker(argv[0]) < 0) { + goto exit_init_data; + } + /* create the consumer instance with and assign the callbacks */ ctx = lttng_consumer_create(opt_type, lttng_consumer_read_subbuffer, NULL, lttng_consumer_on_recv_stream, NULL); @@ -626,17 +625,24 @@ 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) { health_app_destroy(health_consumerd); } -exit_health_consumerd_cleanup: + /* Ensure all prior call_rcu are done. */ + rcu_barrier(); -exit_options: + run_as_destroy_worker(); +exit_health_consumerd_cleanup: +exit_options: exit_set_signal_handler: + if (!retval) { exit(EXIT_SUCCESS); } else {