Fix: consumerd: only return readiness when health is ready
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 27 Jan 2014 03:10:34 +0000 (22:10 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 28 Jan 2014 21:19:41 +0000 (16:19 -0500)
Wait for health check to be ready before returning readiness to session
daemon.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/bin/lttng-consumerd/health-consumerd.c
src/bin/lttng-consumerd/lttng-consumerd.c
src/bin/lttng-consumerd/lttng-consumerd.h

index 413df9acfb92eff3ad4e3566708c7709edd6fe24..ad2b5245a849f769d295f5a51464c973f1145b5b 100644 (file)
@@ -233,6 +233,10 @@ void *thread_manage_health(void *data)
                goto error;
        }
 
+       /* Perform prior memory accesses before decrementing ready */
+       cmm_smp_mb__before_uatomic_dec();
+       uatomic_dec(&lttng_consumer_ready);
+
        while (1) {
                DBG("Health check ready");
 
index 2b5528d64cc4385866761e8df7cdef5f3a5dba8d..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) {
@@ -419,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);
index 5662429ad4c82e958ff47219d88cc8642f173e00..6d18fdf884940c6bc8de351c025f2d6a652c8f34 100644 (file)
 #ifndef _LTTNG_CONSUMERD_H
 #define _LTTNG_CONSUMERD_H
 
+
+#define NR_LTTNG_CONSUMER_READY                1
+extern int lttng_consumer_ready;
+
 const char *tracing_group_name;
 
 enum lttng_consumer_type lttng_consumer_get_type(void);
This page took 0.027475 seconds and 5 git commands to generate.