X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fthread.c;h=a4e3cb86e125f7b3e365a80a27a82e2f610e2323;hb=3a2434036c2e836d58bfa5b89ba47b5898d86d35;hp=26661a36f2aae08c0b21426b9fa343ac9f820a61;hpb=f5fb86c1254b785eee8caf87cb996d33eda0ede9;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/thread.c b/src/bin/lttng-sessiond/thread.c index 26661a36f..a4e3cb86e 100644 --- a/src/bin/lttng-sessiond/thread.c +++ b/src/bin/lttng-sessiond/thread.c @@ -134,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); } @@ -165,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; }