Force usage of assert() condition when NDEBUG is defined
[lttng-tools.git] / src / bin / lttng-sessiond / thread.c
index ed090f6d6b09d65570c4fced29f951d871e1c1a3..a4e3cb86e125f7b3e365a80a27a82e2f610e2323 100644 (file)
@@ -61,9 +61,10 @@ void *launch_thread(void *data)
        void *ret;
        struct lttng_thread *thread = (struct lttng_thread *) data;
 
-       DBG("Launching \"%s\" thread", thread->name);
+       logger_set_thread_name(thread->name, true);
+       DBG("Entering thread entry point");
        ret = thread->entry(thread->data);
-       DBG("Thread \"%s\" has returned", thread->name);
+       DBG("Thread entry point has returned");
        return ret;
 }
 
@@ -133,7 +134,7 @@ void lttng_thread_put(struct lttng_thread *thread)
        if (!thread) {
                return;
        }
-       assert(thread->ref.refcount);
+       LTTNG_ASSERT(thread->ref.refcount);
        urcu_ref_put(&thread->ref, lttng_thread_release);
 }
 
@@ -164,20 +165,22 @@ bool _lttng_thread_shutdown(struct lttng_thread *thread)
                result = false;
                goto end;
        }
-       /* Release the list's reference to the thread. */
-       cds_list_del(&thread->node);
-       lttng_thread_put(thread);
+       DBG("Joined thread \"%s\"", thread->name);
 end:
        return result;
 }
 
 bool lttng_thread_shutdown(struct lttng_thread *thread)
 {
-       bool result;
-
-       pthread_mutex_lock(&thread_list.lock);
-       result = _lttng_thread_shutdown(thread);
-       pthread_mutex_unlock(&thread_list.lock);
+       const bool result = _lttng_thread_shutdown(thread);
+
+       if (result) {
+               /* Release the list's reference to the thread. */
+               pthread_mutex_lock(&thread_list.lock);
+               cds_list_del(&thread->node);
+               lttng_thread_put(thread);
+               pthread_mutex_unlock(&thread_list.lock);
+       }
        return result;
 }
 
This page took 0.025808 seconds and 4 git commands to generate.