[svn:mod_parrot] r601 - in mod_parrot/trunk: include src
[email protected] Sun, 1 Feb 2009 13:10:18 -0800 (PST)
| Newsgroups | perl.cvs.mod_parrot |
|---|---|
| Message-ID | <[email protected]> |
Author: jhorwitz
Date: Sun Feb 1 13:10:16 2009
New Revision: 601
Modified:
mod_parrot/trunk/include/mod_parrot.h
mod_parrot/trunk/src/context.c
mod_parrot/trunk/src/mod_parrot.c
mod_parrot/trunk/src/module.c
Log:
named context pools part 2 (all but metahandlers)
Modified: mod_parrot/trunk/include/mod_parrot.h
==============================================================================
--- mod_parrot/trunk/include/mod_parrot.h (original)
+++ mod_parrot/trunk/include/mod_parrot.h Sun Feb 1 13:10:16 2009
@@ -65,6 +65,7 @@
struct modparrot_context
{
apr_array_header_t *ctx_pool; /* the pool containing this context */
+ char *ctx_pool_name; /* name of the context pool */
Parrot_Interp interp; /* this context's interpreter */
Parrot_Interp parent_interp; /* parent interpreter */
long count; /* number of interpreter invocations */
@@ -121,6 +122,7 @@
Parrot_PMC modparrot_wrap_apache_type(Parrot_Interp, char *, char *, void *);
apr_array_header_t *modparrot_get_named_ctx_pool(const char *);
void modparrot_set_named_ctx_pool(const char *, apr_array_header_t *);
+const char *modparrot_find_ctx_pool_name(apr_pool_t *, apr_array_header_t *);
/* macros for wrapping apache types */
#define modparrot_wrap_apr_pool(i, x) \
Modified: mod_parrot/trunk/src/context.c
==============================================================================
--- mod_parrot/trunk/src/context.c (original)
+++ mod_parrot/trunk/src/context.c Sun Feb 1 13:10:16 2009
@@ -219,13 +219,33 @@
void modparrot_set_named_ctx_pool(const char *name, apr_array_header_t *cp)
{
- apr_hash_set(mp_globals.module_hash, name, APR_HASH_KEY_STRING, cp);
+ air_hash_set(mp_globals.ctx_pool_hash, name, APR_HASH_KEY_STRING, cp);
}
apr_array_header_t *modparrot_get_named_ctx_pool(const char *name)
{
apr_array_header_t *cp;
- cp = apr_hash_get(mp_globals.module_hash, name, APR_HASH_KEY_STRING);
+ cp = apr_hash_get(mp_globals.ctx_pool_hash, name, APR_HASH_KEY_STRING);
return cp;
}
+
+const char *modparrot_find_ctx_pool_name(apr_pool_t *p,
+ apr_array_header_t *ctx_pool)
+{
+ apr_hash_index_t *idx;
+ char *name = NULL;
+
+ for (idx = apr_hash_first(p, mp_globals.ctx_pool_hash); idx;
+ idx = apr_hash_next(idx)) {
+ const void *key;
+ apr_ssize_t klen;
+ void *val;
+ apr_hash_this(idx, &key, &klen, &val);
+ if (val == ctx_pool) {
+ name = (char *)apr_pstrdup(p, (char *)key);
+ break;
+ }
+ }
+ return name;
+}
Modified: mod_parrot/trunk/src/mod_parrot.c
==============================================================================
--- mod_parrot/trunk/src/mod_parrot.c (original)
+++ mod_parrot/trunk/src/mod_parrot.c Sun Feb 1 13:10:16 2009
@@ -246,12 +246,15 @@
MPLOG_ERROR(s, "context pool creation failed");
return NULL;
}
- /* if server doesn't have a context pool, assign this one */
- if (!cfg->ctx_pool) cfg->ctx_pool = ctx_pool;
-
/* name the pool so we can reference it later */
- modparrot_set_named_ctx_pool(name, cfg->ctx_pool);
+ modparrot_set_named_ctx_pool(name, ctx_pool);
MP_TRACE_c(s, "modparrot_startup: context pool %p is named '%s'", ctx_pool, name);
+
+ /* if server doesn't have a context pool, assign this one */
+ if (!cfg->ctx_pool) {
+ cfg->ctx_pool = ctx_pool;
+ MP_TRACE_c(s, "context pool %p (%s) is default for server %p", ctx_pool, name, s);
+ }
}
MP_TRACE_c(s, "modparrot_startup: using context pool %p (%s)", ctx_pool, name);
Modified: mod_parrot/trunk/src/module.c
==============================================================================
--- mod_parrot/trunk/src/module.c (original)
+++ mod_parrot/trunk/src/module.c Sun Feb 1 13:10:16 2009
@@ -201,6 +201,7 @@
modparrot_module_cmd_data *data = cmd->cmd->cmd_data;
modparrot_module_info *minfo = data->modp->dynamic_load_handle;
modparrot_module_config *srvcfg, *dircfg;
+ const char *ctx_pool_name;
int ret;
MP_TRACE_m(cmd->server, \
@@ -208,7 +209,8 @@
cmd->directive->directive);
/* mod_parrot specific stuff */
- ctxp = modparrot_startup(cmd->temp_pool, cmd->server, NULL, NULL);
+ ctx_pool_name = modparrot_find_ctx_pool_name(cmd->pool, minfo->ctx_pool);
+ ctxp = modparrot_startup(cmd->temp_pool, cmd->server, NULL, ctx_pool_name);
ctxp->pconf = cmd->pool;
/* create a ModParrot;Apache;CmdParms object to pass to the handlers */
@@ -573,6 +575,9 @@
minfo->dir_merge_sub = sub;
}
+ /* remember our context pool */
+ minfo->ctx_pool = ctxp->ctx_pool;
+
modp->cmds = cmds; /* our command vector */
modp->register_hooks = register_meta_hooks;