X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fmanage-consumer.c;h=9f3eca3244c52ad2ad9f5ddc884fedaa9e5ef36f;hp=47bfe521cf96056b2ffd7dd111afda69efb0b7e5;hb=2d97a0067600335f07eecb2c1d9ba68fc164583e;hpb=4ec029ed8d032ac98d8dc158a751841b7c150639 diff --git a/src/bin/lttng-sessiond/manage-consumer.c b/src/bin/lttng-sessiond/manage-consumer.c index 47bfe521c..9f3eca324 100644 --- a/src/bin/lttng-sessiond/manage-consumer.c +++ b/src/bin/lttng-sessiond/manage-consumer.c @@ -61,7 +61,7 @@ static void wait_until_thread_is_ready(struct thread_notifiers *notifiers) /* * This thread manage the consumer error sent back to the session daemon. */ -void *thread_consumer_management(void *data) +static void *thread_consumer_management(void *data) { int sock = -1, i, ret, pollfd, err = -1, should_quit = 0; uint32_t revents, nb_fd; @@ -134,11 +134,6 @@ void *thread_consumer_management(void *data) health_code_update(); - if (!revents) { - /* No activity for this FD (poll implementation). */ - continue; - } - /* Thread quit pipe has been closed. Killing thread. */ if (pollfd == quit_pipe_read_fd) { err = 0; @@ -247,8 +242,8 @@ void *thread_consumer_management(void *data) health_code_update(); /* - * Transfer the write-end of the channel monitoring and rotate pipe - * to the consumer by issuing a SET_CHANNEL_MONITOR_PIPE command. + * Transfer the write-end of the channel monitoring pipe to the consumer + * by issuing a SET_CHANNEL_MONITOR_PIPE command. */ cmd_socket_wrapper = consumer_allocate_socket(&consumer_data->cmd_sock); if (!cmd_socket_wrapper) { @@ -257,6 +252,16 @@ void *thread_consumer_management(void *data) } cmd_socket_wrapper->lock = &consumer_data->lock; + pthread_mutex_lock(cmd_socket_wrapper->lock); + ret = consumer_init(cmd_socket_wrapper, sessiond_uuid); + if (ret) { + ERR("Failed to send sessiond uuid to consumer daemon"); + mark_thread_intialization_as_failed(notifiers); + pthread_mutex_unlock(cmd_socket_wrapper->lock); + goto error; + } + pthread_mutex_unlock(cmd_socket_wrapper->lock); + ret = consumer_send_channel_monitor_pipe(cmd_socket_wrapper, consumer_data->channel_monitor_pipe); if (ret) { @@ -298,11 +303,6 @@ void *thread_consumer_management(void *data) health_code_update(); - if (!revents) { - /* No activity for this FD (poll implementation). */ - continue; - } - /* * Thread quit pipe has been triggered, flag that we should stop * but continue the current loop to handle potential data from @@ -447,13 +447,13 @@ bool launch_consumer_management_thread(struct consumer_data *consumer_data) struct thread_notifiers *notifiers = NULL; struct lttng_thread *thread; - quit_pipe = lttng_pipe_open(FD_CLOEXEC); - if (!quit_pipe) { - goto error; - } - notifiers = zmalloc(sizeof(*notifiers)); if (!notifiers) { + goto error_alloc; + } + + quit_pipe = lttng_pipe_open(FD_CLOEXEC); + if (!quit_pipe) { goto error; } notifiers->quit_pipe = quit_pipe; @@ -471,10 +471,11 @@ bool launch_consumer_management_thread(struct consumer_data *consumer_data) wait_until_thread_is_ready(notifiers); lttng_thread_put(thread); if (notifiers->initialization_result) { - goto error; + return false; } return true; error: cleanup_consumer_management_thread(notifiers); +error_alloc: return false; }