Skip to content

Commit

Permalink
Revert "Deautocrap: everybody has a pthread_setname_np(2) now."
Browse files Browse the repository at this point in the history
This reverts commit 41cdd27.

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.
  • Loading branch information
dridi authored and walid-git committed Dec 22, 2024
1 parent e3aa613 commit 32935f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bin/varnishd/cache/cache_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,17 @@ 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__)
(void)pthread_setname_np(pthread_self(), "%s", (char *)(uintptr_t)name);
#else
thr_setname_generic(name);
#endif
#endif
}

const char *
Expand Down
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 32935f5

Please sign in to comment.