From: Jérémie Galarneau Date: Thu, 6 Dec 2018 17:03:48 +0000 (-0500) Subject: Make the launch of the application registration thread blocking X-Git-Tag: v2.12.0-rc1~708 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9c9d917cfe2e6a9f35ef82cb64e442451210716f;p=lttng-tools.git Make the launch of the application registration thread blocking Waiting for the application registration thread to be ready to accept application connection ensures that the application registration socket is created and being listened-to before the parent is signalled. Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/register.c b/src/bin/lttng-sessiond/register.c index 6776019c6..319514a36 100644 --- a/src/bin/lttng-sessiond/register.c +++ b/src/bin/lttng-sessiond/register.c @@ -37,6 +37,7 @@ struct thread_notifiers { struct lttng_pipe *quit_pipe; struct ust_cmd_queue *ust_cmd_queue; + sem_t ready; }; /* @@ -113,6 +114,21 @@ static void cleanup_application_registration_thread(void *data) free(notifiers); } +static +void mark_thread_as_ready(struct thread_notifiers *notifiers) +{ + DBG("Marking application registration thread as ready"); + sem_post(¬ifiers->ready); +} + +static +void wait_until_thread_is_ready(struct thread_notifiers *notifiers) +{ + DBG("Waiting for application registration thread to be ready"); + sem_wait(¬ifiers->ready); + DBG("Application registration thread is ready"); +} + /* * This thread manage application registration. */ @@ -150,6 +166,8 @@ static void *thread_application_registration(void *data) goto error_listen; } + mark_thread_as_ready(notifiers); + /* * Pass 2 as size here for the thread quit pipe and apps_sock. Nothing * more will be added to this poll set. @@ -379,6 +397,7 @@ struct lttng_thread *launch_application_registration_thread( } notifiers->quit_pipe = quit_pipe; notifiers->ust_cmd_queue = cmd_queue; + sem_init(¬ifiers->ready, 0, 0); thread = lttng_thread_create("UST application registration", thread_application_registration, @@ -388,6 +407,7 @@ struct lttng_thread *launch_application_registration_thread( if (!thread) { goto error; } + wait_until_thread_is_ready(notifiers); return thread; error: cleanup_application_registration_thread(notifiers);