Fix: lttng perf counter deadlock
[lttng-ust.git] / liblttng-ust / lttng-ust-comm.c
index 98f9bdb1d99283db3397cb5d19c941fc49c60b8f..f8e450e1d6c3335ceadd59c79fa41768324edf72 100644 (file)
@@ -81,6 +81,8 @@ static int initialized;
  *
  * ust_lock nests within the dynamic loader lock (within glibc) because
  * it is taken within the library constructor.
+ *
+ * The ust fd tracker lock nests within the ust_mutex.
  */
 static pthread_mutex_t ust_mutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -416,6 +418,7 @@ void lttng_ust_fixup_tls(void)
        lttng_fixup_nest_count_tls();
        lttng_fixup_procname_tls();
        lttng_fixup_ust_mutex_nest_tls();
+       lttng_ust_fixup_perf_counter_tls();
        lttng_ust_fixup_fd_tracker_tls();
 }
 
@@ -637,6 +640,10 @@ int handle_register_done(struct sock_info *sock_info)
        sock_info->registration_done = 1;
 
        decrement_sem_count(1);
+       if (!sock_info->statedump_pending) {
+               sock_info->initial_statedump_done = 1;
+               decrement_sem_count(1);
+       }
 
        return 0;
 }
@@ -2020,6 +2027,8 @@ void ust_before_fork(sigset_t *save_sigset)
 
        ust_lock_nocheck();
        rcu_bp_before_fork();
+       lttng_ust_lock_fd_tracker();
+       lttng_perf_lock();
 }
 
 static void ust_after_fork_common(sigset_t *restore_sigset)
@@ -2027,6 +2036,8 @@ static void ust_after_fork_common(sigset_t *restore_sigset)
        int ret;
 
        DBG("process %d", getpid());
+       lttng_perf_unlock();
+       lttng_ust_unlock_fd_tracker();
        ust_unlock();
 
        pthread_mutex_unlock(&ust_fork_mutex);
This page took 0.023367 seconds and 4 git commands to generate.