struct thread_notifiers {
struct lttng_pipe *quit_pipe;
struct ust_cmd_queue *ust_cmd_queue;
+ sem_t ready;
};
/*
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.
*/
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.
return notify_thread_pipe(write_fd) == 1;
}
-bool launch_application_registration_thread(
+struct lttng_thread *launch_application_registration_thread(
struct ust_cmd_queue *cmd_queue)
{
struct lttng_pipe *quit_pipe;
}
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,
if (!thread) {
goto error;
}
- lttng_thread_put(thread);
- return true;
+ wait_until_thread_is_ready(notifiers);
+ return thread;
error:
cleanup_application_registration_thread(notifiers);
- return false;
+ return NULL;
}