]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Add support to ErrorLogFormat for logging the system unique
authorStefan Fritsch <sf@apache.org>
Wed, 22 Jun 2011 20:22:24 +0000 (20:22 +0000)
committerStefan Fritsch <sf@apache.org>
Wed, 22 Jun 2011 20:22:24 +0000 (20:22 +0000)
thread id under Linux

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1138616 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
configure.in
docs/manual/mod/core.xml
server/log.c

diff --git a/CHANGES b/CHANGES
index 41cfceec8695e3e16298efcafd6dc904b2f8e577..f6e3df7cd23845aa8750bbf8c9d6f56ea097ddd7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 
 Changes with Apache 2.3.13
 
+  *) core: Add support to ErrorLogFormat for logging the system unique
+     thread id under Linux. [Stefan Fritsch]
+
   *) event: New AsyncRequestWorkerFactor directive to influence how many
      connections will be accepted per process. [Stefan Fritsch]
 
index 891e26696a124b0c1afdd78da7b36e6ab397a523..dcb3e9dc801b040806db5278757a2eee1f21149f 100644 (file)
@@ -446,6 +446,18 @@ fopen64
 dnl confirm that a void pointer is large enough to store a long integer
 APACHE_CHECK_VOID_PTR_LEN
 
+AC_CACHE_CHECK([for gettid()], ac_cv_gettid,
+[AC_TRY_RUN(#define _GNU_SOURCE
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+int main(int argc, char **argv) {
+pid_t t = syscall(SYS_gettid); return t == -1 ? 1 : 0; },
+[ac_cv_gettid=yes], [ac_cv_gettid=no], [ac_cv_gettid=no])])
+if test "$ac_cv_gettid" = "yes"; then
+    AC_DEFINE(HAVE_GETTID, 1, [Define if you have gettid()])
+fi
+
 dnl check for LDAP support, needed by modules/aaa and modules/ldap
 AP_FIND_LDAP
 
index 271bb20121a47a9f67f5d0ce1fad2c879d85cab6..67e0c8d7cfe4691947516ed5b25adfd699b5b5f2 100644 (file)
@@ -1322,6 +1322,10 @@ in case of an error</description>
     <tr><td><code>%...T</code></td>
         <td>Thread ID of current thread</td></tr>
 
+    <tr><td><code>%...{g}T</code></td>
+        <td>System unique thread ID of current thread (the same ID as
+            displayed by e.g. <code>top</code>; currently Linux only)</td></tr>
+
     <tr><td><code>%...t</code></td>
         <td>The current time</td></tr>
 
index 083b9f91c34a9dc685d081610052cb7820fdb639..252adf6f81220278f8ba0e786ddb9ac3eb16cbf6 100644 (file)
 #include "util_time.h"
 #include "ap_mpm.h"
 
+#if HAVE_GETTID
+#include <sys/syscall.h>
+#include <sys/types.h>
+#endif
+
 /* we know core's module_index is 0 */
 #undef APLOG_MODULE_INDEX
 #define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX
@@ -585,7 +590,16 @@ static int log_tid(const ap_errorlog_info *info, const char *arg,
 {
 #if APR_HAS_THREADS
     int result;
-
+#endif
+#if HAVE_GETTID
+    if (arg && *arg == 'g') {
+        pid_t tid = syscall(SYS_gettid);
+        if (tid == -1)
+            return 0;
+        return apr_snprintf(buf, buflen, "%"APR_PID_T_FMT, tid);
+    }
+#endif
+#if APR_HAS_THREADS
     if (ap_mpm_query(AP_MPMQ_IS_THREADED, &result) == APR_SUCCESS
         && result != AP_MPMQ_NOT_SUPPORTED)
     {