On Thu, 24 Jun 2004, Joe Schaefer wrote:

> Joe Schaefer <[EMAIL PROTECTED]> writes:
>
> > Perhaps using APR_OPTIONAL_FN* will do the trick here?
>
> Proof-of-concept patch below.  I don't know how to produce
> a BOOT stanza in WrapXS/APR/Pool/Pool.xs, so after applying this patch
> you also need to edit that file so the bottom looks like so
[ .. ]

Works great for me - thanks, Joe! Here's a copy of the patch
together with a small addition to lib/ModPerl/WrapXS.pm
which makes that change mentioned above to the end of
APR/APR/Pool/Pool.xs.

=======================================================================
Index: lib/ModPerl/WrapXS.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/ModPerl/WrapXS.pm,v
retrieving revision 1.76
diff -u -r1.76 WrapXS.pm
--- lib/ModPerl/WrapXS.pm       23 Jun 2004 03:30:15 -0000      1.76
+++ lib/ModPerl/WrapXS.pm       25 Jun 2004 02:42:32 -0000
@@ -548,6 +548,10 @@
         }
     }

+    if ($module eq 'APR::Pool') {
+        print $fh "    mpopt_interp_unselect = 
APR_RETRIEVE_OPTIONAL_FN(modperl_interp_unselect);\n\n";
+    }
+
     close $fh;
 }

Index: src/modules/perl/mod_perl.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
retrieving revision 1.214
diff -u -r1.214 mod_perl.c
--- src/modules/perl/mod_perl.c 2 Jun 2004 21:35:58 -0000       1.214
+++ src/modules/perl/mod_perl.c 25 Jun 2004 02:42:32 -0000
@@ -715,6 +715,8 @@

 void modperl_register_hooks(apr_pool_t *p)
 {
+    APR_REGISTER_OPTIONAL_FN(modperl_interp_unselect);
+
     /* for <IfDefine MODPERL2> and Apache->define("MODPERL2") */
     *(char **)apr_array_push(ap_server_config_defines) =
         apr_pstrdup(p, "MODPERL2");
Index: src/modules/perl/mod_perl.h
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.h,v
retrieving revision 1.66
diff -u -r1.66 mod_perl.h
--- src/modules/perl/mod_perl.h 16 Jun 2004 03:55:47 -0000      1.66
+++ src/modules/perl/mod_perl.h 25 Jun 2004 02:42:32 -0000
@@ -128,4 +128,6 @@
 /* we need to hook a few internal things before APR_HOOK_REALLY_FIRST */
 #define MODPERL_HOOK_REALLY_REALLY_FIRST (-20)

+APR_DECLARE_OPTIONAL_FN(apr_status_t,modperl_interp_unselect,(void *));
+
 #endif /*  MOD_PERL_H */
Index: xs/APR/APR/APR.xs
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/APR/APR/APR.xs,v
retrieving revision 1.11
diff -u -r1.11 APR.xs
--- xs/APR/APR/APR.xs   16 Jun 2004 03:55:48 -0000      1.11
+++ xs/APR/APR/APR.xs   25 Jun 2004 02:42:32 -0000
@@ -15,12 +15,6 @@

 #include "mod_perl.h"

-/* XXX: provide the missing symbol for APR::Pool as a tmp workaround  */
-#ifndef modperl_interp_unselect
-apr_status_t modperl_interp_unselect(void *data);
-apr_status_t modperl_interp_unselect(void *data) { return APR_SUCCESS; }
-#endif
-
 #ifdef MP_HAVE_APR_LIBS
 #   define APR_initialize apr_initialize
 #   define APR_terminate  apr_terminate
Index: xs/APR/Pool/APR__Pool.h
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/APR/Pool/APR__Pool.h,v
retrieving revision 1.14
diff -u -r1.14 APR__Pool.h
--- xs/APR/Pool/APR__Pool.h     14 May 2004 07:40:31 -0000      1.14
+++ xs/APR/Pool/APR__Pool.h     25 Jun 2004 02:42:32 -0000
@@ -202,6 +202,9 @@
  * callback wrapper for Perl cleanup subroutines
  * @param data   internal storage
  */
+
+static APR_OPTIONAL_FN_TYPE(modperl_interp_unselect) *mpopt_interp_unselect;
+
 static apr_status_t mpxs_cleanup_run(void *data)
 {
     int count;
@@ -233,12 +236,12 @@
     }

 #ifdef USE_ITHREADS
-    if (cdata->interp) {
+    if (cdata->interp && mpopt_interp_unselect) {
         /* this will decrement the interp refcnt until
          * there are no more references, in which case
          * the interpreter will be putback into the mip
          */
-        (void)modperl_interp_unselect(cdata->interp);
+        (void)mpopt_interp_unselect(cdata->interp);
     }
 #endif

================================================================

-- 
best regards,
randy

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to