From: Stefan Fritsch Date: Wed, 22 Jun 2011 20:22:24 +0000 (+0000) Subject: Add support to ErrorLogFormat for logging the system unique X-Git-Tag: 2.3.13~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bde65f90cb59c4116e5c86f9573fe414835fd395;p=thirdparty%2Fapache%2Fhttpd.git Add support to ErrorLogFormat for logging the system unique thread id under Linux git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1138616 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 41cfceec869..f6e3df7cd23 100644 --- 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] diff --git a/configure.in b/configure.in index 891e26696a1..dcb3e9dc801 100644 --- a/configure.in +++ b/configure.in @@ -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 +#include +#include +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 diff --git a/docs/manual/mod/core.xml b/docs/manual/mod/core.xml index 271bb20121a..67e0c8d7cfe 100644 --- a/docs/manual/mod/core.xml +++ b/docs/manual/mod/core.xml @@ -1322,6 +1322,10 @@ in case of an error %...T Thread ID of current thread + %...{g}T + System unique thread ID of current thread (the same ID as + displayed by e.g. top; currently Linux only) + %...t The current time diff --git a/server/log.c b/server/log.c index 083b9f91c34..252adf6f812 100644 --- a/server/log.c +++ b/server/log.c @@ -54,6 +54,11 @@ #include "util_time.h" #include "ap_mpm.h" +#if HAVE_GETTID +#include +#include +#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) {