From 32935f5abefe0e266a653f96b85750e9a17110a1 Mon Sep 17 00:00:00 2001 From: Dridi Boukelmoune Date: Tue, 7 May 2024 09:52:39 +0200 Subject: [PATCH] Revert "Deautocrap: everybody has a pthread_setname_np(2) now." This reverts commit 41cdd270f72a6972e050c38a0fabb05793044c29. Even though everybody has a pthread_setname_np(3), they are different and not portable by definition. The safeguards should be preserved since THR_SetName() will at least allow a panic to get the thread name. --- bin/varnishd/cache/cache_main.c | 4 ++++ configure.ac | 2 ++ 2 files changed, 6 insertions(+) diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index f33aea55d0..91fbdf6b38 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -152,6 +152,9 @@ THR_SetName(const char *name) { PTOK(pthread_setspecific(name_key, name)); +#if defined(HAVE_PTHREAD_SET_NAME_NP) + pthread_set_name_np(pthread_self(), name); +#elif defined(HAVE_PTHREAD_SETNAME_NP) #if defined(__APPLE__) (void)pthread_setname_np(name); #elif defined(__NetBSD__) @@ -159,6 +162,7 @@ THR_SetName(const char *name) #else thr_setname_generic(name); #endif +#endif } const char * diff --git a/configure.ac b/configure.ac index 44e1ed879c..54b8c9f3ae 100644 --- a/configure.ac +++ b/configure.ac @@ -227,6 +227,8 @@ AC_CHECK_FUNCS([fnmatch], [], [AC_MSG_ERROR([fnmatch(3) is required])]) save_LIBS="${LIBS}" LIBS="${PTHREAD_LIBS}" +AC_CHECK_FUNCS([pthread_set_name_np]) +AC_CHECK_FUNCS([pthread_setname_np]) AC_CHECK_FUNCS([pthread_mutex_isowned_np]) AC_CHECK_FUNCS([pthread_getattr_np]) LIBS="${save_LIBS}"