Fix: consumerd: only return readiness when health is ready
[lttng-tools.git] / src / bin / lttng-consumerd / lttng-consumerd.c
index 04adb973c76a198acd06fa7dc000ead230cca61c..4a9a7a4929200bfd53c838eed13b48f52dd0ae50 100644 (file)
@@ -79,6 +79,8 @@ struct health_app *health_consumerd;
 
 const char *tracing_group_name = DEFAULT_TRACING_GROUP;
 
+int lttng_consumer_ready = NR_LTTNG_CONSUMER_READY;
+
 enum lttng_consumer_type lttng_consumer_get_type(void)
 {
        if (!ctx) {
@@ -340,6 +342,9 @@ int main(int argc, char **argv)
 
        /* Init */
        lttng_consumer_init();
+       /* Init socket timeouts */
+       lttcomm_init();
+       lttcomm_inet_init();
 
        if (!getuid()) {
                /* Set limit for open files */
@@ -416,6 +421,15 @@ int main(int argc, char **argv)
                goto health_error;
        }
 
+       /*
+        * Wait for health thread to be initialized before letting the
+        * sessiond thread reply to the sessiond that we are ready.
+        */
+       while (uatomic_read(&lttng_consumer_ready)) {
+               sleep(1);
+       }
+       cmm_smp_mb();   /* Read ready before following operations */
+
        /* Create thread to manage channels */
        ret = pthread_create(&channel_thread, NULL, consumer_thread_channel_poll,
                        (void *) ctx);
This page took 0.024335 seconds and 4 git commands to generate.