hi

within each bucket brigade is a pool.  according to the docs (apr_bucket.h),
the pool isn't involved with the allocation of the brigade, but rather is
associated with the brigade.

I think that it would be useful to have access to that pool.  in perl, it
would mean that when using a brigade created as

  my $bb = APR::Brigade->new($r->pool, $c->bucket_alloc);

one option for gleaning a pool would be to

  my $pool = $bb->pool

which would (hopefully) provide a pool with a lifetime not shorter than the
data in the brigade.  at least if the brigade is constructed properly, the
pool could be depended upon for other things (such as APIs outside of a
mod_perl environment where $r->pool isn't easily accessible).

anyway, here's a patch to open up $bb->pool

--Geoff
Index: t/apr/.cvsignore
===================================================================
RCS file: /home/cvspublic/modperl-2.0/t/apr/.cvsignore,v
retrieving revision 1.9
diff -u -r1.9 .cvsignore
--- t/apr/.cvsignore    23 Jan 2004 19:34:43 -0000      1.9
+++ t/apr/.cvsignore    27 Jan 2004 19:40:46 -0000
@@ -14,3 +14,4 @@
 threadmutex.t
 finfo.t
 flatten.t
+brigade.t
Index: xs/APR/Brigade/APR__Brigade.h
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/APR/Brigade/APR__Brigade.h,v
retrieving revision 1.6
diff -u -r1.6 APR__Brigade.h
--- xs/APR/Brigade/APR__Brigade.h       27 Jan 2004 16:34:36 -0000      1.6
+++ xs/APR/Brigade/APR__Brigade.h       27 Jan 2004 19:40:46 -0000
@@ -68,6 +68,16 @@
 }
 
 static MP_INLINE
+apr_pool_t *mpxs_APR__Brigade_pool(apr_bucket_brigade *brigade)
+{
+    /* eesh, it's r->pool, and c->pool, but bb->p
+     * let's make Perl consistent, otherwise this could be autogenerated
+     */
+
+    return brigade->p;
+}
+
+static MP_INLINE
 SV *mpxs_APR__Brigade_length(pTHX_ apr_bucket_brigade *bb,
                              int read_all)
 {
Index: xs/maps/apr_functions.map
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/maps/apr_functions.map,v
retrieving revision 1.67
diff -u -r1.67 apr_functions.map
--- xs/maps/apr_functions.map   27 Jan 2004 16:34:36 -0000      1.67
+++ xs/maps/apr_functions.map   27 Jan 2004 19:40:48 -0000
@@ -99,6 +99,7 @@
  mpxs_APR__Brigade_empty        #APR_BRIGADE_EMPTY
  mpxs_APR__Brigade_length | | bb, read_all=1
  mpxs_APR__Brigade_flatten | | bb, pool, sv_len=0
+ mpxs_APR__Brigade_pool
 
 MODULE=APR::Bucket
  mpxs_APR__Bucket_is_flush       #APR_BUCKET_IS_FLUSH
Index: xs/maps/apr_structures.map
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/maps/apr_structures.map,v
retrieving revision 1.10
diff -u -r1.10 apr_structures.map
--- xs/maps/apr_structures.map  17 Dec 2003 19:46:15 -0000      1.10
+++ xs/maps/apr_structures.map  27 Jan 2004 19:40:48 -0000
@@ -28,6 +28,12 @@
 >  list
 </apr_bucket>
 
+<apr_bucket_brigade>
+~  pool
+>  list
+>  bucket_alloc
+</apr_bucket_brigade>
+
 <apr_finfo_t>
    pool
    valid
Index: xs/tables/current/Apache/StructureTable.pm
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/tables/current/Apache/StructureTable.pm,v
retrieving revision 1.36
diff -u -r1.36 StructureTable.pm
--- xs/tables/current/Apache/StructureTable.pm  30 May 2003 12:55:14 -0000      1.36
+++ xs/tables/current/Apache/StructureTable.pm  27 Jan 2004 19:40:49 -0000
@@ -1194,6 +1194,23 @@
     ]
   },
   {
+    'type' => 'apr_bucket_brigade',
+    'elts' => [
+      {
+        'type' => 'apr_pool_t *',
+        'name' => 'p'
+      },
+      {
+        'type' => '_ANON 68',
+        'name' => 'link'
+      },
+      {
+        'type' => 'apr_bucket_alloc_t *',
+        'name' => 'bucket_alloc'
+      }
+    ]
+  },
+  {
     'type' => 'apr_bucket_alloc_t',
     'elts' => []
   },
Index: xs/tables/current/ModPerl/FunctionTable.pm
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v
retrieving revision 1.140
diff -u -r1.140 FunctionTable.pm
--- xs/tables/current/ModPerl/FunctionTable.pm  27 Jan 2004 16:34:36 -0000      1.140
+++ xs/tables/current/ModPerl/FunctionTable.pm  27 Jan 2004 19:40:56 -0000
@@ -6444,6 +6444,16 @@
     ]
   },
   {
+    'return_type' => 'apr_pool_t *',
+    'name' => 'mpxs_APR__Brigade_pool',
+    'args' => [
+      {
+        'type' => 'apr_bucket_brigade *',
+        'name' => 'brigade'
+      },
+    ]
+  },
+  {
     'return_type' => 'SV *',
     'name' => 'mpxs_APR__Brigade_length',
     'args' => [

--- /dev/null   2003-01-30 05:24:37.000000000 -0500
+++ t/response/TestAPR/brigade.pm       2004-01-27 14:36:23.000000000 -0500
@@ -0,0 +1,41 @@
+package TestAPR::brigade;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+
+use Apache::RequestRec ();
+use APR::Brigade ();
+
+use Apache::Const -compile => 'OK';
+
+sub handler {
+
+    my $r = shift;
+
+    plan $r, tests => 4;
+
+    # simple constructor and accessor tests
+
+    my $bb = APR::Brigade->new($r->pool, $r->connection->bucket_alloc);
+
+    t_debug('$bb is defined');
+    ok defined $bb;
+
+    t_debug('$bb ISA APR::Brigade object');
+    ok $bb->isa('APR::Brigade');
+
+    my $pool = $bb->pool;
+
+    t_debug('$pool is defined');
+    ok defined $pool;
+
+    t_debug('$pool ISA APR::Pool object');
+    ok $pool->isa('APR::Pool');
+
+    Apache::OK;
+}
+
+1;

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

Reply via email to