X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=liblttng-ust%2Flttng-ust-comm.c;h=a1ebcbe6fc83564a5fc4d9c0c0642403938da35f;hb=8c90a710949a214d87084ff67fc85f284bc93ef2;hp=bfc9bc5a87f8fc6e02bd5cb3d999f575af1c98dc;hpb=6715d7d1c61b3ffdae9d50aa8875c627900a857f;p=lttng-ust.git diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index bfc9bc5a..a1ebcbe6 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -85,7 +86,7 @@ static int sem_count = { 2 }; * Counting nesting within lttng-ust. Used to ensure that calling fork() * from liblttng-ust does not execute the pre/post fork handlers. */ -static int __thread lttng_ust_nest_count; +static DEFINE_URCU_TLS(int, lttng_ust_nest_count); /* * Info about socket and associated listener thread. @@ -183,7 +184,7 @@ extern void lttng_ring_buffer_metadata_client_exit(void); static void lttng_fixup_nest_count_tls(void) { - asm volatile ("" : : "m" (lttng_ust_nest_count)); + asm volatile ("" : : "m" (URCU_TLS(lttng_ust_nest_count))); } static @@ -621,9 +622,9 @@ int get_wait_shm(struct sock_info *sock_info, size_t mmap_size) * If the open failed because the file did not exist, try * creating it ourself. */ - lttng_ust_nest_count++; + URCU_TLS(lttng_ust_nest_count)++; pid = fork(); - lttng_ust_nest_count--; + URCU_TLS(lttng_ust_nest_count)--; if (pid > 0) { int status; @@ -1213,7 +1214,7 @@ void ust_before_fork(sigset_t *save_sigset) sigset_t all_sigs; int ret; - if (lttng_ust_nest_count) + if (URCU_TLS(lttng_ust_nest_count)) return; /* Disable signals */ sigfillset(&all_sigs); @@ -1240,7 +1241,7 @@ static void ust_after_fork_common(sigset_t *restore_sigset) void ust_after_fork_parent(sigset_t *restore_sigset) { - if (lttng_ust_nest_count) + if (URCU_TLS(lttng_ust_nest_count)) return; DBG("process %d", getpid()); rcu_bp_after_fork_parent(); @@ -1259,7 +1260,7 @@ void ust_after_fork_parent(sigset_t *restore_sigset) */ void ust_after_fork_child(sigset_t *restore_sigset) { - if (lttng_ust_nest_count) + if (URCU_TLS(lttng_ust_nest_count)) return; DBG("process %d", getpid()); /* Release urcu mutexes */