dorian taylor wrote:
Thanks for the idea, dorian. Patches are more than welcome. Look at APR::Pool for an example of how to do it in XS. It should be just 2 lines of code :)

well, it was indeed just a few lines of code (see the patch attached at the end), but we can't do that in a simple alias of destroy to DESTROY. I've implemented it and all the filters went broken. The reason is that the $bb argument passed to the input filters is special [1], the caller expects the callee to fill it in. With implicit DESTROY it gets destroyed before the caller gets it, wrecking havoc. So unless we somehow tag $bb's passed as an argument as special and not eligible for DESTROY, we can't add this change. We already do a similar thing for APR::Pool objects, where native pools like $r->pool, in no way can be destroyed.


[1] http://perl.apache.org/docs/2.0/user/handlers/filters.html#Input_Filters

The simple (not acceptable patch):

Index: Changes
===================================================================
RCS file: /home/cvs/modperl-2.0/Changes,v
retrieving revision 1.413
diff -u -r1.413 Changes
--- Changes     15 Jul 2004 06:23:21 -0000      1.413
+++ Changes     15 Jul 2004 08:03:52 -0000
@@ -12,6 +12,9 @@

 =item 1.99_15-dev

+add APR::Brigade::DESTROY so now there is no need to call an explicit
+$bb->destroy, $bb gets destroyed at the end of the scope [Stas]
+
 fix an old outstanding bug in the APR::Table's TIE interface with
 each()/values() over tables with multi-values keys. Now the produced
 order is correct and consistent with keys(). Though, values() works
Index: xs/APR/Brigade/APR__Brigade.h
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/APR/Brigade/APR__Brigade.h,v
retrieving revision 1.13
diff -u -r1.13 APR__Brigade.h
--- xs/APR/Brigade/APR__Brigade.h       9 Jun 2004 14:46:22 -0000       1.13
+++ xs/APR/Brigade/APR__Brigade.h       15 Jul 2004 08:03:56 -0000
@@ -159,3 +159,5 @@
 {
     MP_RUN_CROAK(apr_brigade_destroy(bb), "APR::Brigade::destroy");
 }
+
+#define mpxs_APR__Brigade_DESTROY(bb) mpxs_APR__Brigade_destroy(aTHX_ bb)
Index: xs/maps/apr_functions.map
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/maps/apr_functions.map,v
retrieving revision 1.83
diff -u -r1.83 apr_functions.map
--- xs/maps/apr_functions.map   15 Jul 2004 06:23:21 -0000      1.83
+++ xs/maps/apr_functions.map   15 Jul 2004 08:03:56 -0000
@@ -82,6 +82,7 @@
  apr_brigade_create | mpxs_ | SV *:CLASS, p, list | new
 ~apr_brigade_destroy
  mpxs_APR__Brigade_destroy
+void:DEFINE_DESTROY | | apr_bucket_brigade *:bb
 !apr_brigade_partition
 !apr_brigade_printf
 -apr_brigade_putstrs

and the doc:

Index: src/docs/2.0/api/APR/Brigade.pod
===================================================================
RCS file: /home/cvs/modperl-docs/src/docs/2.0/api/APR/Brigade.pod,v
retrieving revision 1.10
diff -u -r1.10 Brigade.pod
--- src/docs/2.0/api/APR/Brigade.pod    12 Jul 2004 23:13:22 -0000      1.10
+++ src/docs/2.0/api/APR/Brigade.pod    15 Jul 2004 08:05:29 -0000
@@ -146,6 +146,20 @@



+=head2 C<DESTROY>
+
+Same as C<L<$bb->destroy()|/C_destroy_>>, but invoked implicitly at
+the end of the scope of the bucket brigade object. Normally you should
+rely on C<DESTROY>, and only when you really need to destroy the
+bucket brigade explicitly call C<L<$bb->destroy()|/C_destroy_>>.
+
+=over 4
+
+=item since: 1.99_15
+
+=back
+
+


=head2 C<is_empty>

--
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Reply via email to