+#include <semaphore.h>
+#include <time.h>
+#include <assert.h>
+#include <urcu/uatomic.h>
+
+#include <lttng-ust-comm.h>
+#include <ust/usterr-signal-safe.h>
+#include <ust/lttng-ust-abi.h>
+#include <ust/tracepoint.h>
+
+/*
+ * Has lttng ust comm constructor been called ?
+ */
+static int initialized;
+
+/*
+ * communication thread mutex. Held when handling a command, also held
+ * by fork() to deal with removal of threads, and by exit path.
+ */
+static pthread_mutex_t lttng_ust_comm_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* Should the ust comm thread quit ? */
+static int lttng_ust_comm_should_quit;
+
+/*
+ * Wait for either of these before continuing to the main
+ * program:
+ * - the register_done message from sessiond daemon
+ * (will let the sessiond daemon enable sessions before main
+ * starts.)
+ * - sessiond daemon is not reachable.
+ * - timeout (ensuring applications are resilient to session
+ * daemon problems).
+ */
+static sem_t constructor_wait;
+/*
+ * Doing this for both the global and local sessiond.
+ */
+static int sem_count = { 2 };
+
+/*
+ * Info about socket and associated listener thread.
+ */
+struct sock_info {
+ const char *name;
+ char sock_path[PATH_MAX];
+ int socket;
+ pthread_t ust_listener; /* listener thread */
+ int root_handle;
+ int constructor_sem_posted;
+ int allowed;
+};