[svn:mod_parrot] r525 - mod_parrot/trunk/src
[email protected] Fri, 5 Dec 2008 12:14:05 -0800 (PST)
| Newsgroups | perl.cvs.mod_parrot |
|---|---|
| Message-ID | <[email protected]> |
Author: jhorwitz
Date: Fri Dec 5 12:14:05 2008
New Revision: 525
Modified:
mod_parrot/trunk/src/module.c
Log:
properly register config PMCs returned from merge handlers
implement server merging
Modified: mod_parrot/trunk/src/module.c
==============================================================================
--- mod_parrot/trunk/src/module.c (original)
+++ mod_parrot/trunk/src/module.c Fri Dec 5 12:14:05 2008
@@ -76,7 +76,42 @@
void *modparrot_module_srv_merge(apr_pool_t *p, void *base, void *new)
{
- return(NULL);
+ modparrot_module_config *basecfg =(modparrot_module_config *)base;
+ 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);
+ module *modp = apr_hash_get(mpcfg->module_hash, basecfg->name,
+ APR_HASH_KEY_STRING);
+ modparrot_module_info *minfo = modp->dynamic_load_handle;
+
+ /* if we're here, then by definition we have a merge sub -- MAKE SURE! */
+ assert(minfo->server_merge_sub);
+
+ /* grab our current context. the pool should be the config pool */
+ modparrot_context *ctxp = modparrot_get_current_ctx(p);
+ assert(ctxp);
+
+ mergedcfg->name = basecfg->name; /* XXX should we copy this instead? */
+ mergedcfg->minfo = basecfg->minfo;
+
+ /* unregister existing config */
+ if (mergedcfg->cfg) {
+ if (!PMC_IS_NULL(mergedcfg->cfg)) {
+ Parrot_unregister_pmc(ctxp->interp, mergedcfg->cfg);
+ }
+ }
+
+ /* call merge routine */
+ mergedcfg->cfg = Parrot_call_sub(ctxp->interp, minfo->server_merge_sub,
+ "PPP", basecfg->cfg, newcfg->cfg);
+
+ /* register merged config */
+ if (!PMC_IS_NULL(mergedcfg->cfg)) {
+ Parrot_register_pmc(ctxp->interp, mergedcfg->cfg);
+ }
+
+ return mergedcfg;
}
void *modparrot_module_dir_create(apr_pool_t *p, char *path)
@@ -106,16 +141,26 @@
if (!ctxp) ctxp = modparrot_get_current_ctx(apr_pool_parent_get(p));
assert(ctxp);
- /* XXX dir merges can happen at request time, so need to GC this somehow */
mergedcfg->name = basecfg->name; /* XXX should we copy this instead? */
mergedcfg->minfo = basecfg->minfo;
+
+ /* unregister existing config */
+ if (mergedcfg->cfg) {
+ if (!PMC_IS_NULL(mergedcfg->cfg)) {
+ Parrot_unregister_pmc(ctxp->interp, mergedcfg->cfg);
+ }
+ }
+
+ /* call merge routine */
mergedcfg->cfg = Parrot_call_sub(ctxp->interp, minfo->dir_merge_sub,
"PPP", basecfg->cfg, newcfg->cfg);
+
+ /* register merged config */
if (!PMC_IS_NULL(mergedcfg->cfg)) {
Parrot_register_pmc(ctxp->interp, mergedcfg->cfg);
}
- return mergedcfg;
+ return(mergedcfg);
}
static Parrot_PMC make_cmd_args_array(Parrot_Interp interp, apr_pool_t *p,