[svn:mod_parrot] r518 - mod_parrot/branches/userdata/src

[email protected] Fri, 5 Dec 2008 10:01:03 -0800 (PST)
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Fri Dec  5 10:01:02 2008
New Revision: 518

Modified:
   mod_parrot/branches/userdata/src/mod_parrot.c
   mod_parrot/branches/userdata/src/modparrot_config.c
   mod_parrot/branches/userdata/src/module.c

Log:
bind contexts for pre-mpm phases to temporary pool
child_init handlers manage context lifecycle on their own (they use child pool)


Modified: mod_parrot/branches/userdata/src/mod_parrot.c
==============================================================================
--- mod_parrot/branches/userdata/src/mod_parrot.c	(original)
+++ mod_parrot/branches/userdata/src/mod_parrot.c	Fri Dec  5 10:01:02 2008
@@ -137,6 +137,7 @@
 static modparrot_context *modparrot_get_current_ctx(apr_pool_t *p)
 {
     modparrot_context *ctxp;
+    assert(p);
     apr_pool_userdata_get((void **)&ctxp, MP_KEY_CTX, p);
     return(ctxp);
 }
@@ -160,7 +161,8 @@
 
     cfg = ap_get_module_config(s->module_config, &parrot_module);
 
-    if (!(ctxp = modparrot_get_current_ctx(p))) {
+    if (p) ctxp = modparrot_get_current_ctx(p);
+    if (!ctxp) {
         if ((ctxp = reserve_ctx(cfg->ctx_pool, MP_CTX_ANY))) {
             if (!ctxp->interp) {
                 if (!(interp = modparrot_init(ctxp, s))) {
@@ -175,13 +177,15 @@
             }
 
             /* remember this context for the life of the pool */
-            modparrot_set_current_ctx(p, ctxp);
+            if (p) modparrot_set_current_ctx(p, ctxp);
         }
         else {
             MPLOG_ERROR(s, "init_ctx: no free contexts");
         }
+    }
 
-        /* usually set s in a hook, but need it here for the config phase */
+    /* usually set s in a hook, but need it here for the config phase */
+    if (ctxp) {
         ctxp->s = s;
     }
 
@@ -212,11 +216,6 @@
         return NULL;
     }
 
-    /* we assume that the passed in pool is the configuration pool.  we'll use
-     * this for early startups, but it will be overwritten by later handlers.
-     */
-    ctxp->pconf = p;
-
     return(ctxp);
 }
 
@@ -513,7 +512,7 @@
     modparrot_context *ctxp;
 
     /* initialize context */
-    if (!(ctxp = init_ctx(s, p))) {
+    if (!(ctxp = init_ctx(s, NULL))) {
         MPLOG_ERROR(s, "context initialization failed");
         return;
     }
@@ -529,6 +528,8 @@
     hard_thread_limit = 1;
     max_threads = 1;
 #endif /* MPM_IS_THREADED */
+
+    release_ctx(ctxp);
 }
 
 /* XXX - how do we notify apache of failures with a void return??? */
@@ -542,7 +543,7 @@
     int status;
 
     /* initialize context */
-    if (!(ctxp = init_ctx(s, p))) {
+    if (!(ctxp = init_ctx(s, NULL))) {
         MPLOG_ERROR(s, "context initialization failed");
         return;
     }
@@ -564,8 +565,9 @@
        "child_init_handler", &status)) {
         MPLOG_ERRORF(s, "no child_init metahandler found for module '%s'",
             modp->name);
-        return;
     }
+
+    release_ctx(ctxp);
 }
 
 static int modparrot_post_config_handler(apr_pool_t *pconf, apr_pool_t *plog,
@@ -574,7 +576,7 @@
     modparrot_context *ctxp;
 
     /* initialize context */
-    if (!(ctxp = init_ctx(s, pconf))) {
+    if (!(ctxp = init_ctx(s, ptemp))) {
         MPLOG_ERROR(s, "context initialization failed");
         return HTTP_INTERNAL_SERVER_ERROR;
     }
@@ -597,7 +599,7 @@
     int status;
 
     /* initialize context */
-    if (!(ctxp = init_ctx(s, pconf))) {
+    if (!(ctxp = init_ctx(s, ptemp))) {
         MPLOG_ERROR(s, "context initialization failed");
         return HTTP_INTERNAL_SERVER_ERROR;
     }
@@ -640,9 +642,10 @@
     mpcfg = ap_get_module_config(s->module_config, &parrot_module);
 
     if (mpcfg->option_flags & MP_OPT_ENABLE) {
-        if (!(ctxp = modparrot_startup(pconf, s, NULL))) {
+        if (!(ctxp = modparrot_startup(ptemp, s, NULL))) {
             return HTTP_INTERNAL_SERVER_ERROR;
         }
+        ctxp->pconf = pconf;
         parent_interp = ctxp->interp;
 
         /* we're FIRST, so reset the module index */
@@ -664,9 +667,10 @@
         vscfg = ap_get_module_config(vs->module_config, &parrot_module);
         if (!(vscfg->option_flags & MP_OPT_ENABLE)) continue;
         if (vscfg->option_flags & MP_OPT_PARENT) {
-            if (!(vsctxp = modparrot_startup(pconf, vs, parent_interp))) {
+            if (!(vsctxp = modparrot_startup(ptemp, vs, parent_interp))) {
                 return HTTP_INTERNAL_SERVER_ERROR;
             }
+            vsctxp->pconf = pconf;
 
             /* load ParrotLoad files */
             modparrot_load_files(vsctxp->interp, vs, vscfg->preload);
@@ -703,7 +707,7 @@
     int status;
 
     /* initialize context */
-    if (!(ctxp = init_ctx(s, pconf))) {
+    if (!(ctxp = init_ctx(s, ptemp))) {
         MPLOG_ERROR(s, "context initialization failed");
         return HTTP_INTERNAL_SERVER_ERROR;
     }

Modified: mod_parrot/branches/userdata/src/modparrot_config.c
==============================================================================
--- mod_parrot/branches/userdata/src/modparrot_config.c	(original)
+++ mod_parrot/branches/userdata/src/modparrot_config.c	Fri Dec  5 10:01:02 2008
@@ -204,7 +204,8 @@
     cfg = GET_SERVER_CONFIG(cmd);
 
     /* this will start the interpreter if necessary and return a context */
-    ctxp = modparrot_startup(cmd->pool, cmd->server, NULL);
+    ctxp = modparrot_startup(cmd->temp_pool, cmd->server, NULL);
+    ctxp->pconf = cmd->pool;
 
     modparrot_load_file(ctxp->interp, cmd->server, path);
 

Modified: mod_parrot/branches/userdata/src/module.c
==============================================================================
--- mod_parrot/branches/userdata/src/module.c	(original)
+++ mod_parrot/branches/userdata/src/module.c	Fri Dec  5 10:01:02 2008
@@ -130,7 +130,8 @@
     int ret;
 
     /* mod_parrot specific stuff */
-    ctxp = modparrot_startup(cmd->pool, cmd->server, NULL);
+    ctxp = modparrot_startup(cmd->temp_pool, cmd->server, NULL);
+    ctxp->pconf = cmd->pool;
 
     /* create/fetch module server config */
     srvcfg = (modparrot_module_config *)ap_get_module_config(