Skip to content

Commit

Permalink
audio/pulseaudio: fix thread naming
Browse files Browse the repository at this point in the history
This helps debuggin, at least procstat -kk shows the name of the threads
now.
  • Loading branch information
bapt committed Apr 3, 2024
1 parent 5c82571 commit b97f8ad
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion audio/pulseaudio/Makefile
Expand Up @@ -4,7 +4,7 @@

PORTNAME= pulseaudio
DISTVERSION= 16.1
PORTREVISION= 2
PORTREVISION= 3
CATEGORIES= audio
MASTER_SITES= https://freedesktop.org/software/pulseaudio/releases/

Expand Down
29 changes: 29 additions & 0 deletions audio/pulseaudio/files/patch-src_pulsecore_thread-posix.c
@@ -0,0 +1,29 @@
--- src/pulsecore/thread-posix.c.orig 2022-06-21 10:54:48 UTC
+++ src/pulsecore/thread-posix.c
@@ -71,6 +71,8 @@ static void* internal_thread_func(void *userdata) {
prctl(PR_SET_NAME, t->name);
#elif defined(HAVE_PTHREAD_SETNAME_NP) && defined(OS_IS_DARWIN)
pthread_setname_np(t->name);
+#elif defined(HAVE_PTHREAD_SETNAME_NP) && defined(OS_IS_FREEBSD)
+ pthread_setname_np(t->id, t->name);
#endif

t->id = pthread_self();
@@ -184,6 +186,8 @@ void pa_thread_set_name(pa_thread *t, const char *name
prctl(PR_SET_NAME, name);
#elif defined(HAVE_PTHREAD_SETNAME_NP) && defined(OS_IS_DARWIN)
pthread_setname_np(name);
+#elif defined(HAVE_PTHREAD_SETNAME_NP) && defined(OS_IS_FREEBSD)
+ pthread_setname_np(t->id, t->name);
#endif
}

@@ -201,7 +205,7 @@ const char *pa_thread_get_name(pa_thread *t) {
t->name = NULL;
}
}
-#elif defined(HAVE_PTHREAD_GETNAME_NP) && defined(OS_IS_DARWIN)
+#elif defined(HAVE_PTHREAD_GETNAME_NP) && (defined(OS_IS_DARWIN) || defined(OS_IS_FREEBSD))
if (!t->name) {
t->name = pa_xmalloc0(17);
pthread_getname_np(t->id, t->name, 16);

0 comments on commit b97f8ad

Please sign in to comment.