[svn:mod_parrot] r522 - mod_parrot/trunk/src

[email protected] Fri, 5 Dec 2008 10:47:30 -0800 (PST)
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Fri Dec  5 10:47:29 2008
New Revision: 522

Modified:
   mod_parrot/trunk/src/module.c

Log:
implement HLL module directory merging


Modified: mod_parrot/trunk/src/module.c
==============================================================================
--- mod_parrot/trunk/src/module.c	(original)
+++ mod_parrot/trunk/src/module.c	Fri Dec  5 10:47:29 2008
@@ -87,7 +87,35 @@
 
 void *modparrot_module_dir_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->dir_merge_sub);
+
+    /* grab our current context.  we might be using the request pool before
+     * we've begun the request phase, also check for the context bound to
+     * the connection pool, which is the parent of the request pool */
+    modparrot_context *ctxp = modparrot_get_current_ctx(p);
+    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;
+    mergedcfg->cfg = Parrot_call_sub(ctxp->interp, minfo->dir_merge_sub,
+        "PPP", basecfg->cfg, newcfg->cfg);
+    if (!PMC_IS_NULL(mergedcfg->cfg)) {
+        Parrot_register_pmc(ctxp->interp, mergedcfg->cfg);
+    }
+ 
+    return mergedcfg;
 }
 
 static Parrot_PMC make_cmd_args_array(Parrot_Interp interp, apr_pool_t *p,
@@ -154,7 +182,7 @@
     dircfg = (modparrot_module_config *)mconfig;
     if (dircfg) {
         if (!dircfg->cfg) {
-            srvcfg->name = apr_pstrdup(cmd->pool, data->modp->name);
+            dircfg->name = apr_pstrdup(cmd->pool, data->modp->name);
             if (minfo->dir_create_sub) {
                 /* XXX pass in pool and server_rec objects when implemented */
                 dircfg->cfg = Parrot_call_sub(ctxp->interp,