Revert "sessiond: trigger: run trigger actions through an action executor"
[lttng-tools.git] / src / bin / lttng-sessiond / thread.c
index 7e16b69ed9ca5ddb113875b87cb6fa7be64c48e0..26661a36f2aae08c0b21426b9fa343ac9f820a61 100644 (file)
@@ -1,18 +1,8 @@
 /*
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2 only, as
- * published by the Free Software Foundation.
+ * SPDX-License-Identifier: GPL-2.0-only
  *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #include "thread.h"
@@ -71,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;
 }
 
@@ -88,7 +79,7 @@ struct lttng_thread *lttng_thread_create(const char *name,
 
        thread = zmalloc(sizeof(*thread));
        if (!thread) {
-               goto error;
+               goto error_alloc;
        }
 
        urcu_ref_init(&thread->ref);
@@ -127,9 +118,9 @@ error_pthread_create:
        /* Release list reference. */
        lttng_thread_put(thread);
        pthread_mutex_unlock(&thread_list.lock);
-error:
        /* Release initial reference. */
        lttng_thread_put(thread);
+error_alloc:
        return NULL;
 }
 
@@ -140,6 +131,9 @@ bool lttng_thread_get(struct lttng_thread *thread)
 
 void lttng_thread_put(struct lttng_thread *thread)
 {
+       if (!thread) {
+               return;
+       }
        assert(thread->ref.refcount);
        urcu_ref_put(&thread->ref, lttng_thread_release);
 }
@@ -169,6 +163,7 @@ bool _lttng_thread_shutdown(struct lttng_thread *thread)
        if (ret) {
                PERROR("Failed to join \"%s\" thread", thread->name);
                result = false;
+               goto end;
        }
        /* Release the list's reference to the thread. */
        cds_list_del(&thread->node);
This page took 0.034753 seconds and 5 git commands to generate.