Internal logging lazy-initialization
[lttng-ust.git] / src / lib / lttng-ust / lttng-ust-comm.c
index 219ef5d21ca64a21c08457c86f8b822d73efc540..cd5b378c49be203d8d9fa72e37dc43f327fa86e3 100644 (file)
@@ -25,7 +25,6 @@
 #include <signal.h>
 #include <limits.h>
 #include <urcu/uatomic.h>
-#include "futex.h"
 #include <urcu/compiler.h>
 #include <lttng/urcu/urcu-ust.h>
 
 #include <lttng/ust-thread.h>
 #include <lttng/ust-tracer.h>
 #include <urcu/tls-compat.h>
+#include "common/compat/futex.h"
 #include "common/ustcomm.h"
 #include "common/ust-fd.h"
 #include "common/logging.h"
 #include "common/macros.h"
-#include "tracepoint-internal.h"
+#include "common/tracepoint.h"
 #include "lttng-tracer-core.h"
 #include "common/compat/pthread.h"
 #include "common/procname.h"
@@ -51,8 +51,8 @@
 #include "lttng-ust-statedump.h"
 #include "clock.h"
 #include "lib/lttng-ust/getcpu.h"
-#include "getenv.h"
-#include "ust-events-internal.h"
+#include "common/getenv.h"
+#include "lib/lttng-ust/events.h"
 #include "context-internal.h"
 #include "common/align.h"
 #include "lttng-counter-client.h"
@@ -2120,8 +2120,17 @@ void lttng_ust_init(void)
         * sessiond (otherwise leading to errors when trying to create
         * sessiond before the init functions are completed).
         */
+
+       /*
+        * Both the logging and getenv lazy-initialization uses getenv()
+        * internally and thus needs to be explicitly initialized in
+        * liblttng-ust before we start any threads as an unsuspecting normally
+        * single threaded application using liblttng-ust could be using
+        * setenv() which is not thread-safe.
+        */
        lttng_ust_logging_init();
-       lttng_ust_getenv_init();        /* Needs lttng_ust_logging_init() to be completed. */
+       lttng_ust_getenv_init();
+
        lttng_ust_tp_init();
        lttng_ust_init_fd_tracker();
        lttng_ust_clock_init();
This page took 0.025062 seconds and 4 git commands to generate.