summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-10-20 21:50:49 +0200
committerwm4 <wm4@nowhere>2014-10-20 21:50:49 +0200
commitd38e36b98f249ae1fd30fa9e7a454b784a9b014d (patch)
treee50e0444f5bddaef28a0086daefe40adcce8a66b /osdep
parentc918b8a3f3653e4754b075f80efee440fb5b6512 (diff)
downloadmpv-d38e36b98f249ae1fd30fa9e7a454b784a9b014d.tar.bz2
mpv-d38e36b98f249ae1fd30fa9e7a454b784a9b014d.tar.xz
osdep: shorten thread name on glibc only
Instead of affecting every platform, do this for glibc only (where it's known to be a problem), and only if the right error is returned.
Diffstat (limited to 'osdep')
-rw-r--r--osdep/threads.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/osdep/threads.c b/osdep/threads.c
index 2a5938cee5..7a6174eb79 100644
--- a/osdep/threads.c
+++ b/osdep/threads.c
@@ -15,6 +15,7 @@
* with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
+#include <errno.h>
#include "config.h"
@@ -46,10 +47,13 @@ int mpthread_mutex_init_recursive(pthread_mutex_t *mutex)
void mpthread_set_name(const char *name)
{
- char tname[16];
- snprintf(tname, sizeof(tname), "mpv %s", name);
+ char tname[80];
+ snprintf(tname, sizeof(tname), "mpv/%s", name);
#if HAVE_GLIBC_THREAD_NAME
- pthread_setname_np(pthread_self(), tname);
+ if (pthread_setname_np(pthread_self(), tname) == ERANGE) {
+ tname[15] = '\0'; // glibc-checked kernel limit
+ pthread_setname_np(pthread_self(), tname);
+ }
#elif HAVE_BSD_THREAD_NAME
pthread_set_name_np(pthread_self(), tname);
#elif HAVE_OSX_THREAD_NAME