|
|
0e3136 |
From d4e5b6e1e5585d341d1e51f1ddc637c099111076 Mon Sep 17 00:00:00 2001
|
|
|
0e3136 |
From: Joe Orton <jorton@redhat.com>
|
|
|
0e3136 |
Date: Tue, 7 Jul 2020 09:48:01 +0100
|
|
|
0e3136 |
Subject: [PATCH] Check and use gettid() directly with glibc 2.30+.
|
|
|
0e3136 |
|
|
|
0e3136 |
* configure.in: Check for gettid() and define HAVE_SYS_GETTID if
|
|
|
0e3136 |
gettid() is only usable via syscall().
|
|
|
0e3136 |
|
|
|
0e3136 |
* server/log.c (log_tid): Use gettid() directly if available.
|
|
|
0e3136 |
---
|
|
|
0e3136 |
configure.in | 14 +++++++++-----
|
|
|
0e3136 |
server/log.c | 8 ++++++--
|
|
|
0e3136 |
2 files changed, 15 insertions(+), 7 deletions(-)
|
|
|
0e3136 |
|
|
|
0e3136 |
diff --git a/configure.in b/configure.in
|
|
|
0e3136 |
index 423d58d4b9a..60cbf7b7f81 100644
|
|
|
0e3136 |
--- httpd-2.4.43/configure.in.gettid
|
|
|
0e3136 |
+++ httpd-2.4.43/configure.in
|
|
|
0e3136 |
@@ -478,7 +500,8 @@
|
|
|
0e3136 |
timegm \
|
|
|
0e3136 |
getpgid \
|
|
|
0e3136 |
fopen64 \
|
|
|
0e3136 |
-getloadavg
|
|
|
0e3136 |
+getloadavg \
|
|
|
0e3136 |
+gettid
|
|
|
0e3136 |
)
|
|
|
0e3136 |
|
|
|
0e3136 |
dnl confirm that a void pointer is large enough to store a long integer
|
|
|
0e3136 |
@@ -489,16 +512,19 @@
|
|
|
0e3136 |
APR_ADDTO(HTTPD_LIBS, [-lselinux])
|
|
|
0e3136 |
])
|
|
|
0e3136 |
|
|
|
0e3136 |
-AC_CACHE_CHECK([for gettid()], ac_cv_gettid,
|
|
|
0e3136 |
+if test $ac_cv_func_gettid = no; then
|
|
|
0e3136 |
+ # On Linux before glibc 2.30, gettid() is only usable via syscall()
|
|
|
0e3136 |
+ AC_CACHE_CHECK([for gettid() via syscall], ap_cv_gettid,
|
|
|
0e3136 |
[AC_TRY_RUN(#define _GNU_SOURCE
|
|
|
0e3136 |
#include <unistd.h>
|
|
|
0e3136 |
#include <sys/syscall.h>
|
|
|
0e3136 |
#include <sys/types.h>
|
|
|
0e3136 |
int main(int argc, char **argv) {
|
|
|
0e3136 |
pid_t t = syscall(SYS_gettid); return t == -1 ? 1 : 0; },
|
|
|
0e3136 |
-[ac_cv_gettid=yes], [ac_cv_gettid=no], [ac_cv_gettid=no])])
|
|
|
0e3136 |
-if test "$ac_cv_gettid" = "yes"; then
|
|
|
0e3136 |
- AC_DEFINE(HAVE_GETTID, 1, [Define if you have gettid()])
|
|
|
0e3136 |
+ [ap_cv_gettid=yes], [ap_cv_gettid=no], [ap_cv_gettid=no])])
|
|
|
0e3136 |
+ if test "$ap_cv_gettid" = "yes"; then
|
|
|
0e3136 |
+ AC_DEFINE(HAVE_SYS_GETTID, 1, [Define if you have gettid() via syscall()])
|
|
|
0e3136 |
+ fi
|
|
|
0e3136 |
fi
|
|
|
0e3136 |
|
|
|
0e3136 |
dnl ## Check for the tm_gmtoff field in struct tm to get the timezone diffs
|
|
|
0e3136 |
--- httpd-2.4.43/server/log.c.gettid
|
|
|
0e3136 |
+++ httpd-2.4.43/server/log.c
|
|
|
0e3136 |
@@ -55,7 +55,7 @@
|
|
|
0e3136 |
#include "ap_mpm.h"
|
|
|
0e3136 |
#include "ap_listen.h"
|
|
|
0e3136 |
|
|
|
0e3136 |
-#if HAVE_GETTID
|
|
|
0e3136 |
+#if HAVE_SYS_GETTID
|
|
|
0e3136 |
#include <sys/syscall.h>
|
|
|
0e3136 |
#include <sys/types.h>
|
|
|
0e3136 |
#endif
|
|
|
0e3136 |
@@ -625,14 +625,18 @@
|
|
|
0e3136 |
#if APR_HAS_THREADS
|
|
|
0e3136 |
int result;
|
|
|
0e3136 |
#endif
|
|
|
0e3136 |
-#if HAVE_GETTID
|
|
|
0e3136 |
+#if defined(HAVE_GETTID) || defined(HAVE_SYS_GETTID)
|
|
|
0e3136 |
if (arg && *arg == 'g') {
|
|
|
0e3136 |
+#ifdef HAVE_GETTID
|
|
|
0e3136 |
+ pid_t tid = gettid();
|
|
|
0e3136 |
+#else
|
|
|
0e3136 |
pid_t tid = syscall(SYS_gettid);
|
|
|
0e3136 |
+#endif
|
|
|
0e3136 |
if (tid == -1)
|
|
|
0e3136 |
return 0;
|
|
|
0e3136 |
return apr_snprintf(buf, buflen, "%"APR_PID_T_FMT, tid);
|
|
|
0e3136 |
}
|
|
|
0e3136 |
-#endif
|
|
|
0e3136 |
+#endif /* HAVE_GETTID || HAVE_SYS_GETTID */
|
|
|
0e3136 |
#if APR_HAS_THREADS
|
|
|
0e3136 |
if (ap_mpm_query(AP_MPMQ_IS_THREADED, &result) == APR_SUCCESS
|
|
|
0e3136 |
&& result != AP_MPMQ_NOT_SUPPORTED)
|
|
|
0e3136 |
@@ -966,7 +970,7 @@
|
|
|
0e3136 |
#if APR_HAS_THREADS
|
|
|
0e3136 |
field_start = len;
|
|
|
0e3136 |
len += cpystrn(buf + len, ":tid ", buflen - len);
|
|
|
0e3136 |
- item_len = log_tid(info, NULL, buf + len, buflen - len);
|
|
|
0e3136 |
+ item_len = log_tid(info, "g", buf + len, buflen - len);
|
|
|
0e3136 |
if (!item_len)
|
|
|
0e3136 |
len = field_start;
|
|
|
0e3136 |
else
|