Fix: memory corruption in compat.h
[lttng-ust.git] / liblttng-ust / lttng-ust-comm.c
index cc9b6b5e1e8706a1b941de1b0d09ea37dddaffd3..3959568b8366cd54a3661ad375d725adf0290815 100644 (file)
@@ -106,6 +106,14 @@ static pthread_mutex_t ust_fork_mutex = PTHREAD_MUTEX_INITIALIZER;
 /* Should the ust comm thread quit ? */
 static int lttng_ust_comm_should_quit;
 
+/*
+ * This variable can be tested by applications to check whether
+ * lttng-ust is loaded. They simply have to define their own
+ * "lttng_ust_loaded" weak symbol, and test it. It is set to 1 by the
+ * library constructor.
+ */
+int lttng_ust_loaded __attribute__((weak));
+
 /*
  * Return 0 on success, -1 if should quit.
  * The lock is taken in both cases.
@@ -1547,13 +1555,6 @@ void lttng_ust_malloc_wrapper_init(void)
 {
 }
 
-static
-void init_ust_env(void)
-{
-       if (putenv("LTTNG_UST_LOADED=1"))
-               DBG("Error setting LTTNG_UST_LOADED environment variable");
-}
-
 /*
  * sessiond monitoring thread: monitor presence of global and per-user
  * sessiond by polling the application common named pipe.
@@ -1581,7 +1582,7 @@ void __attribute__((constructor)) lttng_ust_init(void)
        lttng_fixup_procname_tls();
        lttng_fixup_ust_mutex_nest_tls();
 
-       init_ust_env();
+       lttng_ust_loaded = 1;
 
        /*
         * We want precise control over the order in which we construct
This page took 0.023455 seconds and 4 git commands to generate.