[dpdk-dev] [PATCH] eal/linux: truncate thread name
Thomas Monjalon
thomas at monjalon.net
Fri Jul 10 14:41:35 CEST 2020
10/07/2020 11:45, David Marchand:
> pthread_setname_np refuses names larger than 16 bytes (\0 included).
> Rather than return an error, truncate the name to this limit in the
> rte_thread_setname helper.
[...]
> --- a/lib/librte_eal/linux/eal_thread.c
> +++ b/lib/librte_eal/linux/eal_thread.c
> @@ -153,7 +153,10 @@ int rte_thread_setname(pthread_t id, const char *name)
> int ret = ENOSYS;
> #if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
> #if __GLIBC_PREREQ(2, 12)
> - ret = pthread_setname_np(id, name);
> + char truncated[16];
That's a pity POSIX is not defining a constant for this limit.
> +
> + strlcpy(truncated, name, sizeof(truncated));
> + ret = pthread_setname_np(id, truncated);
> #endif
> #endif
Acked-by: Thomas Monjalon <thomas at monjalon.net>
More information about the dev
mailing list