From: Yann Ylavic Date: Thu, 16 Jun 2022 14:25:05 +0000 (+0000) Subject: core: log_tid support on FreeBSD. X-Git-Tag: 2.5.0-alpha2-ci-test-only~291 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4234718917924ac696f66dc71ef2b7b4e6e68cc;p=thirdparty%2Fapache%2Fhttpd.git core: log_tid support on FreeBSD. Use pthread_getthreadid_np() when available. BZ: 65835 Submitted by: David CARLIER git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1901975 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/configure.in b/configure.in index 78bcf9baff4..dbc9ea8536b 100644 --- a/configure.in +++ b/configure.in @@ -474,6 +474,7 @@ unistd.h \ sys/socket.h \ pwd.h \ grp.h \ +pthread_np.h \ strings.h \ sys/prctl.h \ sys/procctl.h \ @@ -535,6 +536,7 @@ initgroups \ bindprocessor \ prctl \ procctl \ +pthread_getthreadid_np \ timegm \ getpgid \ fopen64 \ diff --git a/server/log.c b/server/log.c index 89e1679fed6..6295f1a89c4 100644 --- a/server/log.c +++ b/server/log.c @@ -61,6 +61,10 @@ #include #endif +#ifdef HAVE_PTHREAD_NP_H +#include +#endif + /* we know core's module_index is 0 */ #undef APLOG_MODULE_INDEX #define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX @@ -538,10 +542,12 @@ static int log_tid(const ap_errorlog_info *info, const char *arg, #if APR_HAS_THREADS int result; #endif -#if defined(HAVE_GETTID) || defined(HAVE_SYS_GETTID) +#if defined(HAVE_GETTID) || defined(HAVE_SYS_GETTID) || defined(HAVE_PTHREAD_GETTHREADID_NP) if (arg && *arg == 'g') { -#ifdef HAVE_GETTID +#if defined(HAVE_GETTID) pid_t tid = gettid(); +#elif defined(HAVE_PTHREAD_GETTHREADID_NP) + pid_t tid = pthread_getthreadid_np(); #else pid_t tid = syscall(SYS_gettid); #endif