X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbin%2Flttng-consumerd%2Flttng-consumerd.c;h=cf9cb205c35ba73b600bb08125ced84dbb43aada;hb=5c635c724d60fe8e8bfeb00907dfa1e113cc3548;hp=59397594b914c2c99533ff408d77d9c824c08034;hpb=d3e2ba59faddb31870e2ce29b6a881f7ad5ad883;p=lttng-tools.git diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c index 59397594b..cf9cb205c 100644 --- a/src/bin/lttng-consumerd/lttng-consumerd.c +++ b/src/bin/lttng-consumerd/lttng-consumerd.c @@ -47,15 +47,17 @@ #include #include #include +#include #include "lttng-consumerd.h" +#include "health-consumerd.h" /* TODO : support UST (all direct kernel-ctl accesses). */ /* threads (channel handling, poll, metadata, sessiond) */ -static pthread_t channel_thread, data_thread, metadata_thread, sessiond_thread; -static pthread_t metadata_timer_thread; +static pthread_t channel_thread, data_thread, metadata_thread, + sessiond_thread, metadata_timer_thread, health_thread; /* to count the number of times the user pressed ctrl+c */ static int sigintcount = 0; @@ -72,6 +74,17 @@ static enum lttng_consumer_type opt_type = LTTNG_CONSUMER_KERNEL; /* the liblttngconsumerd context */ static struct lttng_consumer_local_data *ctx; +/* Consumerd health monitoring */ +struct health_app *health_consumerd; + +enum lttng_consumer_type lttng_consumer_get_type(void) +{ + if (!ctx) { + return LTTNG_CONSUMER_UNKNOWN; + } + return ctx->type; +} + /* * Signal handler for the daemon */ @@ -325,6 +338,11 @@ int main(int argc, char **argv) set_ulimit(); } + health_consumerd = health_app_create(NR_HEALTH_CONSUMERD_TYPES); + if (!health_consumerd) { + goto error; + } + /* 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); @@ -377,12 +395,25 @@ int main(int argc, char **argv) /* Initialize communication library */ lttcomm_init(); + ret = utils_create_pipe(health_quit_pipe); + if (ret < 0) { + goto error_health_pipe; + } + + /* Create thread to manage the client socket */ + ret = pthread_create(&health_thread, NULL, + thread_manage_health, (void *) NULL); + if (ret != 0) { + PERROR("pthread_create health"); + goto health_error; + } + /* Create thread to manage channels */ ret = pthread_create(&channel_thread, NULL, consumer_thread_channel_poll, (void *) ctx); if (ret != 0) { perror("pthread_create"); - goto error; + goto channel_error; } /* Create thread to manage the polling/writing of trace metadata */ @@ -454,6 +485,17 @@ metadata_error: goto error; } +channel_error: + ret = pthread_join(health_thread, &status); + if (ret != 0) { + PERROR("pthread_join health thread"); + goto error; /* join error, exit without cleanup */ + } + +health_error: + utils_close_pipe(health_quit_pipe); + +error_health_pipe: if (!ret) { ret = EXIT_SUCCESS; lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_EXIT_SUCCESS); @@ -469,6 +511,9 @@ error: end: lttng_consumer_destroy(ctx); lttng_consumer_cleanup(); + if (health_consumerd) { + health_app_destroy(health_consumerd); + } return ret; }