Front page | perl.cvs.mod_parrot |
Postings from January 2009
[svn:mod_parrot] r596 - in mod_parrot/trunk: include src
From:
jhorwitz
Date:
January 24, 2009 09:56
Subject:
[svn:mod_parrot] r596 - in mod_parrot/trunk: include src
Message ID:
20090124175559.28B7DCB9AE@x12.develooper.com
Author: jhorwitz
Date: Sat Jan 24 09:55:57 2009
New Revision: 596
Modified:
mod_parrot/trunk/include/modparrot_log.h
mod_parrot/trunk/src/context.c
mod_parrot/trunk/src/mod_parrot.c
mod_parrot/trunk/src/module.c
Log:
add context activity tracing
Modified: mod_parrot/trunk/include/modparrot_log.h
==============================================================================
--- mod_parrot/trunk/include/modparrot_log.h (original)
+++ mod_parrot/trunk/include/modparrot_log.h Sat Jan 24 09:55:57 2009
@@ -46,6 +46,10 @@
#define MPLOG_DEBUGF(s, fmt, msg) \
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, fmt, msg)
+void modparrot_trace(server_rec *, const char *, ...);
+
+#ifdef MODPARROT_DEBUG
+
#define MP_DEBUG_NONE 0
#define MP_DEBUG_MODULE 1
#define MP_DEBUG_CONTEXT 2
@@ -58,6 +62,13 @@
#define MP_TRACE_p if (modparrot_debug_level & MP_DEBUG_PARROT) modparrot_trace
#define MP_TRACE_m if (modparrot_debug_level & MP_DEBUG_MODULE) modparrot_trace
-void modparrot_trace(server_rec *, const char *, ...);
+#else /* MODPARROT_DEBUG */
+
+#define MP_TRACE_h if (0) modparrot_trace
+#define MP_TRACE_c if (0) modparrot_trace
+#define MP_TRACE_p if (0) modparrot_trace
+#define MP_TRACE_m if (0) modparrot_trace
+
+#endif /* MODPARROT_DEBUG */
#endif /* _MODPARROT_LOG_H */
Modified: mod_parrot/trunk/src/context.c
==============================================================================
--- mod_parrot/trunk/src/context.c (original)
+++ mod_parrot/trunk/src/context.c Sat Jan 24 09:55:57 2009
@@ -32,11 +32,14 @@
#include "mod_parrot.h"
#include "modparrot_config.h"
+#include "modparrot_log.h"
#ifdef MPM_IS_THREADED
apr_thread_mutex_t *ctx_pool_mutex;
#endif /* MPM_IS_THREADED */
+extern server_rec *base_server;
+
/* initialize pool of contexts */
apr_array_header_t * mp_ctx_pool_init(apr_pool_t *p,
Parrot_Interp parent_interp, int num)
@@ -45,6 +48,8 @@
apr_array_header_t *ctx_pool;
modparrot_context *ctx;
+ MP_TRACE_c(base_server, "creating context pool of size %d", num);
+
if (!(ctx_pool = apr_array_make(p, num, sizeof(modparrot_context)))) {
return NULL;
}
@@ -62,6 +67,8 @@
}
#endif /* MPM_IS_THREADED */
+ MP_TRACE_c(base_server, "created context pool %p (size %d)", ctx_pool, num);
+
return ctx_pool;
}
@@ -72,6 +79,8 @@
if (!ctx_pool) return;
+ MP_TRACE_c(base_server, "destroying context pool %p", ctx_pool);
+
/* pop each context off the list and destroy its interpreter */
#ifdef MPM_IS_THREADED
apr_thread_mutex_lock(ctx_pool_mutex);
@@ -99,6 +108,9 @@
modparrot_context *ctxp = (modparrot_context *)NULL;
if (!ctx_pool) return NULL;
+
+ MP_TRACE_c(base_server, "reserving a context from pool %p", ctx_pool);
+
#ifdef MPM_IS_THREADED
apr_thread_mutex_lock(ctx_pool_mutex);
if (index == MP_CTX_ANY) {
@@ -126,12 +138,16 @@
ctxp = ((modparrot_context **)ctx_pool->elts)[0];
MODPARROT_CTX_LOCK(ctxp); /* no threads here, just for consistency */
#endif /* MPM_IS_THREADED */
+
+ MP_TRACE_c(base_server, "reserved context %p from pool %p", ctx_pool, ctxp);
+
return(ctxp);
}
/* releases a context back into the pool of available contexts */
void release_ctx(modparrot_context *ctxp)
{
+ MP_TRACE_c(base_server, "releasing context %p", ctxp);
MODPARROT_CTX_UNLOCK(ctxp);
}
@@ -196,5 +212,6 @@
void modparrot_set_current_ctx(apr_pool_t *p, modparrot_context *ctxp)
{
+ MP_TRACE_c(base_server, "binding context %p to APR pool %p", ctxp, p);
apr_pool_userdata_set(ctxp, MP_KEY_CTX, modparrot_ctx_cleanup, p);
}
Modified: mod_parrot/trunk/src/mod_parrot.c
==============================================================================
--- mod_parrot/trunk/src/mod_parrot.c (original)
+++ mod_parrot/trunk/src/mod_parrot.c Sat Jan 24 09:55:57 2009
@@ -60,6 +60,9 @@
/* debug level */
int modparrot_debug_level = 0;
+/* base server_rec for when we have no other way of obtaining it */
+server_rec *base_server = NULL;
+
void modparrot_trace(server_rec *s, const char *fmt, ...)
{
va_list ap;
@@ -197,6 +200,8 @@
ctxp->s = s;
}
+ MP_TRACE_c(s, "init_ctx: using context %p", ctxp);
+
return(ctxp);
}
@@ -209,6 +214,8 @@
cfg = ap_get_module_config(s->module_config, &parrot_module);
+ if (!mp_is_started) base_server = s;
+
if (!mp_is_started || (!cfg->ctx_pool && s->is_virtual)) {
if (!(cfg->ctx_pool = mp_ctx_pool_init(p, parent_interp, 1))) {
MPLOG_ERROR(s, "context pool creation failed");
Modified: mod_parrot/trunk/src/module.c
==============================================================================
--- mod_parrot/trunk/src/module.c (original)
+++ mod_parrot/trunk/src/module.c Sat Jan 24 09:55:57 2009
@@ -37,8 +37,7 @@
extern module AP_MODULE_DECLARE_DATA parrot_module;
AP_DECLARE_DATA extern module *ap_top_module;
-/* used when we have no other way of getting the server config */
-static server_rec *our_server;
+extern server_rec *base_server;
static apr_status_t modparrot_remove_module(void *data)
{
@@ -80,7 +79,7 @@
modparrot_module_config *newcfg =(modparrot_module_config *)new;
modparrot_module_config *mergedcfg = modparrot_create_module_config(p);
modparrot_srv_config *mpcfg =
- ap_get_module_config(our_server->module_config, &parrot_module);
+ ap_get_module_config(base_server->module_config, &parrot_module);
module *modp = apr_hash_get(mpcfg->module_hash, basecfg->name,
APR_HASH_KEY_STRING);
modparrot_module_info *minfo = modp->dynamic_load_handle;
@@ -103,7 +102,7 @@
}
/* call merge routine */
- MP_TRACE_m(our_server, "calling server_merge for module '%s'", modp->name);
+ MP_TRACE_m(base_server, "calling server_merge for module '%s'", modp->name);
mergedcfg->cfg = Parrot_call_sub(ctxp->interp, minfo->server_merge_sub,
"PPP", basecfg->cfg, newcfg->cfg);
@@ -127,7 +126,7 @@
modparrot_module_config *newcfg =(modparrot_module_config *)new;
modparrot_module_config *mergedcfg = modparrot_create_module_config(p);
modparrot_srv_config *mpcfg =
- ap_get_module_config(our_server->module_config, &parrot_module);
+ ap_get_module_config(base_server->module_config, &parrot_module);
module *modp = apr_hash_get(mpcfg->module_hash, basecfg->name,
APR_HASH_KEY_STRING);
modparrot_module_info *minfo = modp->dynamic_load_handle;
@@ -153,7 +152,7 @@
}
/* call merge routine */
- MP_TRACE_m(our_server, "calling dir_merge for module '%s'", modp->name);
+ MP_TRACE_m(base_server, "calling dir_merge for module '%s'", modp->name);
mergedcfg->cfg = Parrot_call_sub(ctxp->interp, minfo->dir_merge_sub,
"PPP", basecfg->cfg, newcfg->cfg);
@@ -312,7 +311,7 @@
static int module_index = 0;
/* this assumes we're called in the same order modules were added */
- mpcfg = ap_get_module_config(our_server->module_config, &parrot_module);
+ mpcfg = ap_get_module_config(base_server->module_config, &parrot_module);
modp = ((module **)mpcfg->module_array->elts)[module_index];
minfo = modp->dynamic_load_handle;
@@ -326,7 +325,7 @@
pidx = (int *)apr_array_push(mpcfg->handler_modules[i]);
*pidx = module_index;
- MP_TRACE_m(our_server, "registering hook %d for module '%s'", i, modp->name);
+ MP_TRACE_m(base_server, "registering hook %d for module '%s'", i, modp->name);
/* register this hook with apache */
switch(i) {
@@ -439,9 +438,6 @@
}
}
- /* save for later use by register_meta_hooks */
- our_server = ctxp->s;
-
mpcfg = ap_get_module_config(s->module_config, &parrot_module);
for (i = 0; i < num; i++) {
-
[svn:mod_parrot] r596 - in mod_parrot/trunk: include src
by jhorwitz