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

[email protected] Sun, 8 Feb 2009 08:58:15 -0800 (PST)
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Sun Feb  8 08:58:14 2009
New Revision: 610

Modified:
   mod_parrot/trunk/src/mod_parrot.c

Log:
release cloned contexts


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  8 08:58:14 2009
@@ -435,7 +435,7 @@
 #define MP_REQUEST_METAHANDLER(hname, henum, register_cleanup) \
     int modparrot_meta_##hname(request_rec *r) \
     { \
-        modparrot_context *ctxp; \
+        modparrot_context *ctxp, *cloned; \
         modparrot_module_config *dircfg; \
         modparrot_srv_config *mpcfg; \
         module *modp; \
@@ -454,8 +454,12 @@
         /* get next module in line */ \
         if (!(mpcfg->option_flags & MP_OPT_ENABLE)) return DECLINED; \
         modp = NEXT_HANDLER_MODULE(henum); \
-        ctxp = clone_ctx_state(ctxp, select_ctx_pool(modp, r->server, NULL), \
-            r->server, r->pool); \
+        cloned = clone_ctx_state(ctxp, \
+            select_ctx_pool(modp, r->server, NULL), r->server, r->pool); \
+        if (cloned != ctxp) { \
+            release_ctx(ctxp); \
+            ctxp = cloned; \
+        } \
         /* take this opportunity to register the request cleanup handler \
          * here, as we may not handle any other part of the request until \
          * then. NOTE: this is mod_parrot internal only and NOT for HLLs. \
@@ -501,7 +505,7 @@
 
 int modparrot_meta_pre_connection_handler(conn_rec *c, void *csd)
 {
-    modparrot_context *ctxp;
+    modparrot_context *ctxp, *cloned;
     modparrot_srv_config *mpcfg;
     module *modp;
     modparrot_module_info *minfo;
@@ -523,8 +527,12 @@
     /* get next module in line */
     modp = NEXT_HANDLER_MODULE(MP_HOOK_PRE_CONNECTION);
 
-    ctxp = clone_ctx_state(ctxp, select_ctx_pool(modp, c->base_server, NULL),
+    cloned = clone_ctx_state(ctxp, select_ctx_pool(modp, c->base_server, NULL),
         c->base_server, c->pool);
+    if (cloned != ctxp) {
+        release_ctx(ctxp);
+        ctxp = cloned;
+    }
 
     ctxp->c = c;
     ctxp->csd = csd;
@@ -568,7 +576,7 @@
 
 int modparrot_meta_process_connection_handler(conn_rec *c)
 {
-    modparrot_context *ctxp;
+    modparrot_context *ctxp, *cloned;
     modparrot_srv_config *mpcfg;
     module *modp;
     modparrot_module_info *minfo;
@@ -590,8 +598,12 @@
     /* get next module in line */
     modp = NEXT_HANDLER_MODULE(MP_HOOK_PROCESS_CONNECTION);
 
-    ctxp = clone_ctx_state(ctxp, select_ctx_pool(modp, c->base_server, NULL),
+    cloned = clone_ctx_state(ctxp, select_ctx_pool(modp, c->base_server, NULL),
         c->base_server, c->pool);
+    if (cloned != ctxp) {
+        release_ctx(ctxp);
+        ctxp = cloned;
+    }
 
     ctxp->c = c;
 
@@ -644,7 +656,7 @@
 /* XXX - how do we notify apache of failures with a void return??? */
 void modparrot_meta_child_init_handler(apr_pool_t *p, server_rec *s)
 {
-    modparrot_context *ctxp;
+    modparrot_context *ctxp, *cloned;
     modparrot_srv_config *mpcfg;
     module *modp;
     modparrot_module_info *minfo;
@@ -666,7 +678,11 @@
     /* get next module in line */
     modp = NEXT_HANDLER_MODULE(MP_HOOK_CHILD_INIT);
 
-    ctxp = clone_ctx_state(ctxp, select_ctx_pool(modp, s, NULL), s, p);
+    cloned = clone_ctx_state(ctxp, select_ctx_pool(modp, s, NULL), s, p);
+    if (cloned != ctxp) {
+        release_ctx(ctxp);
+        ctxp = cloned;
+    }
 
     ctxp->pchild = p;
     ctxp->s = s;
@@ -713,7 +729,7 @@
 int modparrot_meta_post_config_handler(apr_pool_t *pconf,
     apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
 {
-    modparrot_context *ctxp;
+    modparrot_context *ctxp, *cloned;
     modparrot_srv_config *mpcfg;
     module *modp;
     modparrot_module_info *minfo;
@@ -735,7 +751,11 @@
     /* get next module in line */
     modp = NEXT_HANDLER_MODULE(MP_HOOK_POST_CONFIG);
 
-    ctxp = clone_ctx_state(ctxp, select_ctx_pool(modp, s, NULL), s, ptemp);
+    cloned = clone_ctx_state(ctxp, select_ctx_pool(modp, s, NULL), s, ptemp);
+    if (cloned != ctxp) {
+        release_ctx(ctxp);
+        ctxp = cloned;
+    }
 
     ctxp->pconf = pconf;
     ctxp->plog = plog;
@@ -837,7 +857,7 @@
     apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
 {
     apr_array_header_t *ctx_pool;
-    modparrot_context *ctxp;
+    modparrot_context *ctxp, *cloned;
     modparrot_srv_config *mpcfg;
     module *modp;
     modparrot_module_info *minfo;
@@ -855,7 +875,11 @@
     /* get next module in line */
     modp = NEXT_HANDLER_MODULE(MP_HOOK_OPEN_LOGS);
 
-    ctxp = clone_ctx_state(ctxp, select_ctx_pool(modp, s, NULL), s, ptemp);
+    cloned = clone_ctx_state(ctxp, select_ctx_pool(modp, s, NULL), s, ptemp);
+    if (cloned != ctxp) {
+        release_ctx(ctxp);
+        ctxp = cloned;
+    }
 
     /* decline if mod_parrot isn't enabled -- but open_logs must return OK */
     mpcfg = ap_get_module_config(s->module_config, &parrot_module);