Clean-up: sessiond manage-consumer: change space to tabs
[lttng-tools.git] / src / bin / lttng-sessiond / manage-consumer.c
index fa802adc91e33cd7e3ba92edfc1546a5f50b9016..380cd057c906ba2856881cb238cd517ecd588fd7 100644 (file)
@@ -1,20 +1,10 @@
 /*
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
- *                      Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *               2013 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2 only,
- * as published by the Free Software Foundation.
+ * SPDX-License-Identifier: GPL-2.0-only
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #include <signal.h>
@@ -32,7 +22,7 @@
 struct thread_notifiers {
        struct lttng_pipe *quit_pipe;
        struct consumer_data *consumer_data;
-        sem_t ready;
+       sem_t ready;
        int initialization_result;
 };
 
@@ -46,7 +36,7 @@ static void mark_thread_as_ready(struct thread_notifiers *notifiers)
 static void mark_thread_intialization_as_failed(
                struct thread_notifiers *notifiers)
 {
-        ERR("Consumer management thread entering error state");
+       ERR("Consumer management thread entering error state");
        notifiers->initialization_result = -1;
        sem_post(&notifiers->ready);
 }
@@ -61,7 +51,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;
@@ -242,8 +232,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) {
@@ -252,6 +242,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) {
This page took 0.025348 seconds and 5 git commands to generate.