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

[email protected] Tue, 9 Dec 2008 09:29:37 -0800 (PST)
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Tue Dec  9 09:29:36 2008
New Revision: 537

Modified:
   mod_parrot/trunk/src/mod_parrot.c
   mod_parrot/trunk/src/nci.c

Log:
mark cleanup handler data PMC so it doesn't get collected before cleanup


Modified: mod_parrot/trunk/src/mod_parrot.c
==============================================================================
--- mod_parrot/trunk/src/mod_parrot.c	(original)
+++ mod_parrot/trunk/src/mod_parrot.c	Tue Dec  9 09:29:36 2008
@@ -297,6 +297,11 @@
     status = Parrot_call_sub_ret_int(ctxp->interp, ci->callback, "IP",
         ci->hll_data);
 
+    /* we don't need the data PMC anymore */
+    if (!PMC_IS_NULL(data)) {
+        Parrot_unregister_pmc(ctxp->interp, data);
+    }
+
     return status;
 }
 

Modified: mod_parrot/trunk/src/nci.c
==============================================================================
--- mod_parrot/trunk/src/nci.c	(original)
+++ mod_parrot/trunk/src/nci.c	Tue Dec  9 09:29:36 2008
@@ -414,6 +414,11 @@
     cfg = ap_get_module_config(ctxp->s->module_config, &parrot_module);
     modp = ((module **)cfg->module_array->elts)[ctxp->module_index];
 
+    /* register the data PMC b/c it will likely go out of scope in the HLL */
+    if (!PMC_IS_NULL(data)) {
+        Parrot_register_pmc(interp, data);
+    }
+
     /* populate cleanup info */
     ci = apr_pcalloc(p, sizeof(modparrot_cleanup_info));
     ci->module = modp;