You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by rj...@apache.org on 2010/02/23 07:21:43 UTC
svn commit: r915199 - in /tomcat/jk/trunk: native/common/jk_mt.h
native/common/jk_types.h.in native/common/jk_util.c
native/common/portable.h.sample native/configure.in
xdocs/miscellaneous/changelog.xml
Author: rjung
Date: Tue Feb 23 06:21:42 2010
New Revision: 915199
URL: http://svn.apache.org/viewvc?rev=915199&view=rev
Log:
Automatically detect size of thread id for logging.
We want the logged id to be as close as possible to
the one logged by Apache with %{tid}P and by gstack
resp. pstack.
Modified:
tomcat/jk/trunk/native/common/jk_mt.h
tomcat/jk/trunk/native/common/jk_types.h.in
tomcat/jk/trunk/native/common/jk_util.c
tomcat/jk/trunk/native/common/portable.h.sample
tomcat/jk/trunk/native/configure.in
tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml
Modified: tomcat/jk/trunk/native/common/jk_mt.h
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_mt.h?rev=915199&r1=915198&r2=915199&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_mt.h (original)
+++ tomcat/jk/trunk/native/common/jk_mt.h Tue Feb 23 06:21:42 2010
@@ -71,7 +71,10 @@
#define JK_LEAVE_CS(x, rc)\
if(pthread_mutex_unlock(x)) rc = JK_FALSE; else rc = JK_TRUE
-jk_uint32_t jk_gettid(void);
+#ifdef AS400
+#define jk_pthread_t jk_uint32_t
+#endif /* AS400 */
+jk_pthread_t jk_gettid(void);
#endif /* WIN32 */
#else /* !_MT_CODE */
Modified: tomcat/jk/trunk/native/common/jk_types.h.in
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_types.h.in?rev=915199&r1=915198&r2=915199&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_types.h.in (original)
+++ tomcat/jk/trunk/native/common/jk_types.h.in Tue Feb 23 06:21:42 2010
@@ -56,6 +56,12 @@
/* And JK_PID_T_FMT */
@pid_t_fmt@
+/* jk_pthread_t defines a eight byte word */
+typedef unsigned @pthread_t_value@ jk_pthread_t;
+
+/* And JK_PTHREAD_T_FMT */
+@pthread_t_fmt@
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
Modified: tomcat/jk/trunk/native/common/jk_util.c
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_util.c?rev=915199&r1=915198&r2=915199&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_util.c (original)
+++ tomcat/jk/trunk/native/common/jk_util.c Tue Feb 23 06:21:42 2010
@@ -726,7 +726,7 @@
/* Performance is no issue, because with production log levels */
/* we only call it often, if we have a lot of errors */
rc = snprintf(buf + used, usable_size - used,
- "[%" JK_PID_T_FMT ":%" JK_UINT32_T_FMT "] ", getpid(), jk_gettid());
+ "[%" JK_PID_T_FMT ":%" JK_PTHREAD_T_FMT "] ", getpid(), jk_gettid());
used += rc;
if (rc < 0 ) {
return 0;
@@ -2125,7 +2125,7 @@
}
#ifdef _MT_CODE_PTHREAD
-jk_uint32_t jk_gettid()
+jk_pthread_t jk_gettid()
{
union {
pthread_t tid;
@@ -2141,17 +2141,7 @@
pthread_getunique_np(&(u.tid), &tid);
return ((jk_uint32_t)(tid.intId.lo & 0xFFFFFFFF));
#else
- switch (sizeof(pthread_t)) {
- case sizeof(jk_uint32_t):
- return ((jk_uint32_t)u.tid >> 2);
- break;
- case sizeof(jk_uint64_t):
- return (jk_uint32_t)((((jk_uint64_t)u.tid) >> 3) & 0xFFFFFFFF);
- break;
- default:
- return 0;
- break;
- }
+ return ((jk_pthread_t)u.tid);
#endif /* AS400 */
}
#endif
Modified: tomcat/jk/trunk/native/common/portable.h.sample
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/portable.h.sample?rev=915199&r1=915198&r2=915199&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/portable.h.sample (original)
+++ tomcat/jk/trunk/native/common/portable.h.sample Tue Feb 23 06:21:42 2010
@@ -108,6 +108,9 @@
/* The size of pid_t */
#define SIZEOF_PID_T 4
+/* The size of pthread_t */
+#define SIZEOF_PTHREAD_T 4
+
/* The size of `short', as computed by sizeof. */
#define SIZEOF_SHORT 2
Modified: tomcat/jk/trunk/native/configure.in
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/configure.in?rev=915199&r1=915198&r2=915199&view=diff
==============================================================================
--- tomcat/jk/trunk/native/configure.in (original)
+++ tomcat/jk/trunk/native/configure.in Tue Feb 23 06:21:42 2010
@@ -247,6 +247,24 @@
pid_t_fmt='#error Can not determine the proper size for pid_t'
fi
+JK_CHECK_SIZEOF_EXTENDED([#include <pthread.h>], pthread_t, 8)
+
+if test "$ac_cv_sizeof_pthread_t" = "$ac_cv_sizeof_short"; then
+ pthread_t_fmt='#define JK_PTHREAD_T_FMT "hu"'
+ pthread_t_value="short"
+elif test "$ac_cv_sizeof_pthread_t" = "$ac_cv_sizeof_int"; then
+ pthread_t_fmt='#define JK_PTHREAD_T_FMT "u"'
+ pthread_t_value="int"
+elif test "$ac_cv_sizeof_pthread_t" = "$ac_cv_sizeof_long"; then
+ pthread_t_fmt='#define JK_PTHREAD_T_FMT "lu"'
+ pthread_t_value="long"
+elif test "$ac_cv_sizeof_pthread_t" = "$ac_cv_sizeof_long_long"; then
+ pthread_t_fmt='#define JK_PTHREAD_T_FMT "llu"'
+ pthread_t_value="long long"
+else
+ pthread_t_fmt='#error Can not determine the proper size for pthread_t'
+fi
+
# Basically, we have tried to figure out the correct format strings
# for pid_t which varies between platforms, but we don't always get
# it right. If you find that we don't get it right for your platform,
@@ -268,6 +286,8 @@
AC_SUBST(uint64_t_fmt)
AC_SUBST(uint64_t_hex_fmt)
AC_SUBST(pid_t_fmt)
+AC_SUBST(pthread_t_fmt)
+AC_SUBST(pthread_t_value)
dnl check for snprintf and vsnprintf.
AC_CHECK_FUNC(snprintf, AC_DEFINE(HAVE_SNPRINTF,1,[Have snprintf()]))
Modified: tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml?rev=915199&r1=915198&r2=915199&view=diff
==============================================================================
--- tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml Tue Feb 23 06:21:42 2010
@@ -140,6 +140,9 @@
LB: Fix route logging. (rjung)
</fix>
<update>
+ Logging: Automatically detect size of thread id for logging. (rjung)
+ </update>
+ <update>
Logging: Add optional log file locking for Windows when defining
JK_LOG_LOCKING. (mturk)
</update>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org