From: Mathieu Desnoyers Date: Mon, 27 Jan 2014 03:10:34 +0000 (-0500) Subject: Fix: consumerd: only return readiness when health is ready X-Git-Tag: v2.4.0-rc4~24 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c0c8588600f7a7dfbf030f6985e976ae0b5eed3c;p=lttng-tools.git Fix: consumerd: only return readiness when health is ready Wait for health check to be ready before returning readiness to session daemon. Signed-off-by: Mathieu Desnoyers --- diff --git a/src/bin/lttng-consumerd/health-consumerd.c b/src/bin/lttng-consumerd/health-consumerd.c index 413df9acf..ad2b5245a 100644 --- a/src/bin/lttng-consumerd/health-consumerd.c +++ b/src/bin/lttng-consumerd/health-consumerd.c @@ -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(<tng_consumer_ready); + while (1) { DBG("Health check ready"); diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c index 2b5528d64..4a9a7a492 100644 --- a/src/bin/lttng-consumerd/lttng-consumerd.c +++ b/src/bin/lttng-consumerd/lttng-consumerd.c @@ -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(<tng_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); diff --git a/src/bin/lttng-consumerd/lttng-consumerd.h b/src/bin/lttng-consumerd/lttng-consumerd.h index 5662429ad..6d18fdf88 100644 --- a/src/bin/lttng-consumerd/lttng-consumerd.h +++ b/src/bin/lttng-consumerd/lttng-consumerd.h @@ -19,6 +19,10 @@ #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);