Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On Linux use the real thread id via gettid() in error logging rather #443

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes-entries/linux-log-tid.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*) core: On Linux, log the real thread ID in error logs. [Joe Orton]
6 changes: 6 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,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>
Expand Down
6 changes: 5 additions & 1 deletion server/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
#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;
Expand Down Expand Up @@ -907,7 +911,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
Expand Down