mirror of
https://github.com/mpv-player/mpv
synced 2025-01-08 16:10:29 +00:00
osdep: limit thread names to 16 characters
It turns out the glibc people are very clever and return an error if the thread name exceeds the maximum supported kernel length, instead of truncating the name. So everyone has to hardcode the currently allowed Linux kernel name length limit, even if it gets extended later. Also the Lua script filenames could get too long; use the client name instead. Another strange thing is that on Linux, unrelated threads "inherit" the name by the thread they were created. This leads to random thread names, because there's not necessarily a strong relation between these threads (e.g. script command leads to filter recreation -> the filter's threads are tagged with the script's thread name). Unfortunate.
This commit is contained in:
parent
1aae992585
commit
600221e723
@ -46,7 +46,7 @@ int mpthread_mutex_init_recursive(pthread_mutex_t *mutex)
|
||||
|
||||
void mpthread_set_name(const char *name)
|
||||
{
|
||||
char tname[90];
|
||||
char tname[16];
|
||||
snprintf(tname, sizeof(tname), "mpv %s", name);
|
||||
#if HAVE_GLIBC_THREAD_NAME
|
||||
pthread_setname_np(pthread_self(), tname);
|
||||
|
@ -80,7 +80,7 @@ static void *script_thread(void *p)
|
||||
struct thread_arg *arg = p;
|
||||
|
||||
char name[90];
|
||||
snprintf(name, sizeof(name), "script (%s)", arg->fname);
|
||||
snprintf(name, sizeof(name), "lua (%s)", mpv_client_name(arg->client));
|
||||
mpthread_set_name(name);
|
||||
|
||||
if (arg->backend->load(arg->client, arg->fname) < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user