]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1917578 from trunk:
authorJoe Orton <jorton@apache.org>
Fri, 21 Jun 2024 14:31:54 +0000 (14:31 +0000)
committerJoe Orton <jorton@apache.org>
Fri, 21 Jun 2024 14:31:54 +0000 (14:31 +0000)
On Linux use the real thread id via gettid() in error logging,
where available, rather than the (meaningless) default
pthread_self()-as-integer interpretation:

* configure.in: Define DEFAULT_LOG_TID on Linux if gettid() is available.

* server/log.c: Define DEFAULT_LOG_TID as NULL by default.
  (do_errorlog_default): Use DEFAULT_LOG_TID as the argument to log_tid().

Reviewed by: jorton, ylavic, icing

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1918489 13f79535-47bb-0310-9956-ffa450edef68

changes-entries/linux-log-tid.txt [new file with mode: 0644]
configure.in
server/log.c

diff --git a/changes-entries/linux-log-tid.txt b/changes-entries/linux-log-tid.txt
new file mode 100644 (file)
index 0000000..9f6ce95
--- /dev/null
@@ -0,0 +1 @@
+ *) core: On Linux, log the real thread ID in error logs.  [Joe Orton]
index 8134a69d2af08460b902cb926b396b1cbcab7be7..d2a009d790204c8507cf74e94136bbd501c81abc 100644 (file)
@@ -545,6 +545,12 @@ pid_t t = syscall(SYS_gettid); return t == -1 ? 1 : 0; },
   fi
 fi
 
+case ${host}X${ac_cv_func_gettid}X${ap_cv_gettid} in
+*linux-*XyesX* | *linux-*XnoXyes)
+     AC_DEFINE(DEFAULT_LOG_TID, ["g"], [Define as default argument for thread id in error logging])
+     ;;
+esac
+
 dnl ## Check for the tm_gmtoff field in struct tm to get the timezone diffs
 AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
 [AC_TRY_COMPILE([#include <sys/types.h>
index 22d2f8d9e469faafd1b68027bd66679c4d7ff2bf..9576d071c275dcca8432c2748014237786e2acf2 100644 (file)
 #undef APLOG_MODULE_INDEX
 #define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX
 
+#ifndef DEFAULT_LOG_TID
+#define DEFAULT_LOG_TID NULL
+#endif
+
 typedef struct {
     const char *t_name;
     int t_val;
@@ -990,7 +994,7 @@ static int do_errorlog_default(const ap_errorlog_info *info, char *buf,
 #if APR_HAS_THREADS
         field_start = len;
         len += cpystrn(buf + len, ":tid ", buflen - len);
-        item_len = log_tid(info, NULL, buf + len, buflen - len);
+        item_len = log_tid(info, DEFAULT_LOG_TID, buf + len, buflen - len);
         if (!item_len)
             len = field_start;
         else