X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Ferror.c;h=7ededdb734251e73e0a63a5dbf5705237cf9041e;hp=70063e5044400ab521f8e9b1383728f1fb71e359;hb=1405051ad116a8bd42b68822be6d2f9b3def6c65;hpb=159b042f34366d0fde5dcd73b4231c558922a664 diff --git a/src/common/error.c b/src/common/error.c index 70063e504..7ededdb73 100644 --- a/src/common/error.c +++ b/src/common/error.c @@ -8,13 +8,15 @@ #define _LGPL_SOURCE #include #include +#include #include #include -#include -#include #include +#include +#include #include +#include #include "error.h" @@ -28,6 +30,7 @@ static int lttng_opt_abort_on_error = -1; /* TLS variable that contains the time of one single log entry. */ DEFINE_URCU_TLS(struct log_time, error_log_time); +DEFINE_URCU_TLS(const char *, logger_thread_name); LTTNG_HIDDEN const char *log_add_time(void) @@ -66,6 +69,23 @@ error: return ""; } +LTTNG_HIDDEN +void logger_set_thread_name(const char *name, bool set_pthread_name) +{ + int ret; + + assert(name); + URCU_TLS(logger_thread_name) = name; + + if (set_pthread_name) { + ret = lttng_thread_setname(name); + if (ret && ret != -ENOSYS) { + /* Don't fail as this is not essential. */ + DBG("Failed to set pthread name attribute"); + } + } +} + /* * Human readable error message. */