On Fri, 25 Jun 2004, Stas Bekman wrote:

> Randy Kobes wrote:
> > 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.
[ .. ]
> neat! Great idea Joe!
>
> > +        (void)mpopt_interp_unselect(cdata->interp);
>
> but please use modperl_opt_ prefix if that's OK with you.

Here's another version of the patch with the prefix changed.
It also adds an #ifdef USE_ITHREADS/#endif around the
APR_REGISTER_OPTIONAL_FN(modperl_interp_unselect) of
mod_perl.c, which I needed on my (non-multi-thread) linux.
=========================================================
? s.txt
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 14:54:24 -0000
@@ -548,6 +548,10 @@
         }
     }

+    if ($module eq 'APR::Pool') {
+        print $fh "    modperl_opt_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 14:54:24 -0000
@@ -715,6 +715,11 @@

 void modperl_register_hooks(apr_pool_t *p)
 {
+
+#ifdef USE_ITHREADS
+    APR_REGISTER_OPTIONAL_FN(modperl_interp_unselect);
+#endif
+
     /* 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 14:54:24 -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 14:54:24 -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 14:54:24 -0000
@@ -202,6 +202,9 @@
  * callback wrapper for Perl cleanup subroutines
  * @param data   internal storage
  */
+
+static APR_OPTIONAL_FN_TYPE(modperl_interp_unselect) *modperl_opt_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 && modperl_opt_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)modperl_opt_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