stas 2004/05/09 19:37:05
Modified: src/modules/perl modperl_util.h modperl_util.c
Log:
define thread id and perl id macros for format and value, to simplify the
tracing code and use it.
Revision Changes Path
1.57 +25 -0 modperl-2.0/src/modules/perl/modperl_util.h
Index: modperl_util.h
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_util.h,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -u -r1.56 -r1.57
--- modperl_util.h 4 May 2004 06:19:11 -0000 1.56
+++ modperl_util.h 10 May 2004 02:37:05 -0000 1.57
@@ -188,6 +188,31 @@
/* dump the contents of PL_modglobal */
void modperl_perl_modglobal_dump(pTHX);
+#if APR_HAS_THREADS
+#define MP_TRACEf_TID "/tid 0x%lx"
+#define MP_TRACEv_TID (unsigned long)apr_os_thread_current()
+#define MP_TRACEv_TID_ MP_TRACEv_TID,
+#define MP_TRACEv__TID ,MP_TRACEv_TID
+#else
+#define MP_TRACEf_TID
+#define MP_TRACEv_TID
+#define MP_TRACEv_TID_
+#define MP_TRACEv__TID
+#endif /* APR_HAS_THREADS */
+
+#ifdef USE_ITHREADS
+#define MP_TRACEf_PERLID "/perl id 0x%lx"
+#define MP_TRACEv_PERLID (unsigned long)my_perl
+#define MP_TRACEv_PERLID_ MP_TRACEv_PERLID,
+#define MP_TRACEv__PERLID ,MP_TRACEv_PERLID
+#else
+#define MP_TRACEf_PERLID
+#define MP_TRACEv_PERLID
+#define MP_TRACEv_PERLID_
+#define MP_TRACEv__PERLID
+#endif /* USE_ITHREADS */
+
#endif
+
#endif /* MODPERL_UTIL_H */
1.69 +6 -11 modperl-2.0/src/modules/perl/modperl_util.c
Index: modperl_util.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_util.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -u -r1.68 -r1.69
--- modperl_util.c 10 May 2004 01:08:30 -0000 1.68
+++ modperl_util.c 10 May 2004 02:37:05 -0000 1.69
@@ -298,15 +298,8 @@
/* used in debug traces */
MP_INLINE char *modperl_pid_tid(apr_pool_t *p)
{
- return apr_psprintf(p, "%lu"
-#if APR_HAS_THREADS
- "/%lu"
-#endif /* APR_HAS_THREADS */
- , (unsigned long)getpid()
-#if APR_HAS_THREADS
- , (unsigned long)apr_os_thread_current()
-#endif /* APR_HAS_THREADS */
- );
+ return apr_psprintf(p, "%lu" MP_TRACEf_TID,
+ (unsigned long)getpid() MP_TRACEv__TID);
}
@@ -536,8 +529,10 @@
I32 i, oldscope = PL_scopestack_ix;
SV **ary = AvARRAY(subs);
- MP_TRACE_g(MP_FUNC, "pid %lu running %d %s subs",
- (unsigned long)getpid(), AvFILLp(subs)+1, name);
+ MP_TRACE_g(MP_FUNC, "pid %lu" MP_TRACEf_TID MP_TRACEf_PERLID
+ " running %d %s subs",
+ (unsigned long)getpid(), MP_TRACEv_TID_ MP_TRACEv_PERLID_
+ AvFILLp(subs)+1, name);
for (i=0; i<=AvFILLp(subs); i++) {
CV *cv = (CV*)ary[i];