perl-docs-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject cvs commit: modperl-docs/src/docs/2.0/user/handlers filters.pod protocols.pod
Date Mon, 04 Oct 2004 02:15:50 GMT
joes        2004/10/03 19:15:49

  Modified:    src/docs/2.0/api/APR Brigade.pod Bucket.pod
               src/docs/2.0/api/Apache RequestRec.pod
               src/docs/2.0/user/handlers filters.pod protocols.pod
  Log:
  Reimplement APR::Bucket using apr_bucket_alloc_t -
  
    * $bucket_alloc argument added to APR::Bucket::new
  
    * new subs:
        APR::Bucket::setaside
        APR::Bucket::alloc_create
        APR::Bucket::alloc_destroy
        APR::Brigade::bucket_alloc
  
    * new setaside implementation, using pool buckets
      instead of heap buckets for better performance
      and leak safety.
  
  Reviewed by: stas
  
  Revision  Changes    Path
  1.11      +28 -3     modperl-docs/src/docs/2.0/api/APR/Brigade.pod
  
  Index: Brigade.pod
  ===================================================================
  RCS file: /home/cvs/modperl-docs/src/docs/2.0/api/APR/Brigade.pod,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Brigade.pod	12 Jul 2004 23:13:22 -0000	1.10
  +++ Brigade.pod	4 Oct 2004 02:15:49 -0000	1.11
  @@ -389,6 +389,31 @@
   
   
   
  +=head2 C<bucket_alloc>
  +
  +  my $ba = $bb->bucket_alloc();
  +  $bb2->bucket_alloc($ba);
  +
  +=over 4
  +
  +=item obj: C<$bb>
  +( C<L<APR::Brigade object or class|docs::2.0::api::APR::Brigade>> )
  +
  +
  +=item opt arg1: C<$bucket_alloc>
  +( C<L<APR::BucketAlloc object|docs::2.0::api::APR::BucketAlloc>> )
  +
  +Get/set the bucket allocator associated with this brigade.
  +
  +=item since: 1.99_17
  +
  +=back
  +
  +
  +
  +
  +
  +
   =head2 C<next>
   
   Return the next bucket in a brigade
  @@ -525,9 +550,9 @@
   brigade such that the second brigade will have the last two buckets.
   
     my $bb1 = APR::Brigade->new($r->pool, $c->bucket_alloc);
  -  $bb1->insert_tail(APR::Bucket->new("1"));
  -  $bb1->insert_tail(APR::Bucket->new("2"));
  -  $bb1->insert_tail(APR::Bucket->new("3"));
  +  $bb1->insert_tail(APR::Bucket->new($c->bucket_alloc, "1"));
  +  $bb1->insert_tail(APR::Bucket->new($c->bucket_alloc, "2"));
  +  $bb1->insert_tail(APR::Bucket->new($c->bucket_alloc, "3"));
   
   C<$bb1> now contains buckets "1", "2", "3". Now do the split at the
   second bucket:
  
  
  
  1.14      +114 -17   modperl-docs/src/docs/2.0/api/APR/Bucket.pod
  
  Index: Bucket.pod
  ===================================================================
  RCS file: /home/cvs/modperl-docs/src/docs/2.0/api/APR/Bucket.pod,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Bucket.pod	21 Aug 2004 00:48:47 -0000	1.13
  +++ Bucket.pod	4 Oct 2004 02:15:49 -0000	1.14
  @@ -10,7 +10,7 @@
     use APR::Bucket ();
     my $ba = $c->bucket_alloc;
     
  -  $b1 = APR::Bucket->new("aaa");
  +  $b1 = APR::Bucket->new($ba, "aaa");
     $b2 = APR::Bucket::eos_create($ba);
     $b3 = APR::Bucket::flush_create($ba);
     
  @@ -44,8 +44,8 @@
   to visualize the operations:
   
     my $bb = APR::Brigade->new($r->pool, $ba);
  -  my $d1 = APR::Bucket->new("d1");
  -  my $d2 = APR::Bucket->new("d2");
  +  my $d1 = APR::Bucket->new($ba, "d1");
  +  my $d2 = APR::Bucket->new($ba, "d2");
     my $f1 = APR::Bucket::flush_create($ba);
     my $f2 = APR::Bucket::flush_create($ba);
     my $e1 = APR::Bucket::eos_create($ba);
  @@ -105,7 +105,7 @@
   
     for (my $b = $bb->first; $b; $b = $bb->next($b)) {
        if ($b->read(my $data)) {
  -          my $nb = APR::Bucket->new(uc $data);
  +          my $nb = APR::Bucket->new($bb->bucket_alloc, uc $data);
             $b->insert_before($nb);
             $b->delete;
             $b = $nb;
  @@ -152,6 +152,70 @@
   
   
   
  +=head2 C<alloc_create>
  +
  +Create an C<APR::BucketAlloc> freelist.
  +
  +  $ba = APR::Bucket::alloc_create($pool);
  +
  +=over 4
  +
  +=item arg1: C<$pool>
  +( C<L<APR::Pool object|docs::2.0::api::APR::Pool>> )
  +
  +The pool used to create this this freelist.
  +
  +=item ret: C<$ba>
  +( C<L<APR::BucketAlloc object|docs::2.0::api::APR::BucketAlloc>> )
  +
  +The new freelist.
  +
  +=item since: 1.99_17
  +
  +=back
  +
  +These freelists are used to create new buckets and bucket
  +brigades.  Normally it is not necesssary to create them,
  +since the existing bucket brigades and/or connection objects 
  +in modperl-2 provide them automatically.
  +
  +Example:
  +
  +  use APR::Bucket ();
  +  use Apache::Connection ();
  +  my $ba = APR::Bucket::alloc_create($c->$pool);
  +  my $eos_b = APR::Bucket::eos_create($ba);
  +
  +
  +
  +
  +
  +=head2 C<alloc_destroy>
  +
  +Destroy an C<APR::BucketAlloc> freelist.
  +
  +  APR::Bucket::alloc_destroy($ba);
  +
  +=over 4
  +
  +=item arg1: C<$ba>
  +( C<L<APR::BucketAlloc object|docs::2.0::api::APR::BucketAlloc>> )
  +
  +The freelist to destroy.
  +
  +=item since: 1.99_17
  +
  +=back
  +
  +Destroys the freelist; this object may not be used again.
  +Normally it is not necessary to destroy allocators, since
  +the pool which created them will destroy them during pool
  +cleanup.
  +
  +
  +
  +
  +
   =head2 C<eos_create>
   
   Create an I<EndOfStream> bucket.
  @@ -351,17 +415,20 @@
   
   Create a new bucket and initialize it with data:
   
  -  $nb = APR::Bucket->new($data);
  -  $nb =          $b->new($data);
  -  $nb = APR::Bucket->new($data, $offset);
  -  $nb = APR::Bucket->new($data, $offset, $len);
  +  $nb = APR::Bucket->new($bucket_alloc, $data);
  +  $nb =          $b->new($bucket_alloc, $data);
  +  $nb = APR::Bucket->new($bucket_alloc, $data, $offset);
  +  $nb = APR::Bucket->new($bucket_alloc, $data, $offset, $len);
   
   =over 4
   
   =item obj: C<$b>
   ( C<L<APR::Bucket object or class|docs::2.0::api::APR::Bucket>> )
   
  -=item arg1: C<$data> ( string )
  +=item arg1: C<$bucket_alloc>
  +( C<L<APR::BucketAlloc object|docs::2.0::api::APR::BucketAlloc>> )
  +
  +=item arg2: C<$data> ( string )
   
   The data to initialize with.
   
  @@ -370,11 +437,11 @@
   after passing it to C<new()> you will modify the data in the bucket as
   well. To avoid that pass to C<new()> a copy which you won't modify.
   
  -=item opt arg2: C<$offset> ( number )
  +=item opt arg3: C<$offset> ( number )
   
   Optional offset inside C<$data>. Default: 0.
   
  -=item opt arg3: C<$len> ( number )
  +=item opt arg4: C<$len> ( number )
   
   Optional partial length to read.
   
  @@ -391,7 +458,7 @@
   
   a newly created bucket object
   
  -=item since: 1.99_10
  +=item since: 1.99_17
   
   =back
   
  @@ -405,7 +472,7 @@
   
     use APR::Bucket ();
     my $data = "my data";
  -  my $b = APR::Bucket->new($data);
  +  my $b = APR::Bucket->new($ba, $data);
   
   now the bucket contains the string I<'my data'>.
   
  @@ -416,7 +483,7 @@
     use APR::Bucket ();
     my $data   = "my data";
     my $offset = 3;
  -  my $b = APR::Bucket->new($data, $offset);
  +  my $b = APR::Bucket->new($ba, $data, $offset);
   
   now the bucket contains the string I<'data'>.
   
  @@ -429,7 +496,7 @@
     my $data   = "my data";
     my $offset = 3;
     my $len    = 3;
  -  my $b = APR::Bucket->new($data, $offset, $len);
  +  my $b = APR::Bucket->new($ba, $data, $offset, $len);
   
   now the bucket contains the string I<'dat'>.
   
  @@ -443,7 +510,7 @@
   
   Read the data from the bucket.
   
  -  $len = $b->read($buffer,);
  +  $len = $b->read($buffer);
     $len = $b->read($buffer, $block);
   
   =over 4
  @@ -546,6 +613,36 @@
   
   
   
  +=head2 C<setaside>
  +
  +Ensure the bucket's data lasts at least as long as the given pool.
  +
  +
  +  my $status = $bucket->setaside($pool);
  +
  +=over 4
  +
  +=item obj: C<$bucket>
  +( C<L<APR::Bucket object|docs::2.0::api::APR::Bucket>> )
  +
  +=item arg1: C<$pool>
  +( C<L<APR::Pool object|docs::2.0::api::APR::Pool>> )
  +
  +=item ret: status code- APR_SUCCESS or error condition.
  +
  +=item since: 1.99_17
  +
  +=back
  +
  +When the a modperl bucket is setaside, its data is detached from the 
  +original perl scalar and copied into a pool bucket. Usually setaside
  +is called by certain output filters, in order to buffer socket writes 
  +of smaller buckets into a single write.
  +
  +
  +
  +
  +
   =head2 C<type>
   
   Get the type of the data in the bucket.
  @@ -621,7 +718,7 @@
   It gives the offset to when a new bucket is created with a non-zero
   offset value:
   
  -  my $b = APR::Bucket->new($data, $offset, $len);
  +  my $b = APR::Bucket->new($ba, $data, $offset, $len);
   
   So if the offset was 3. C<$start> will be 3 too.
   
  
  
  
  1.33      +1 -1      modperl-docs/src/docs/2.0/api/Apache/RequestRec.pod
  
  Index: RequestRec.pod
  ===================================================================
  RCS file: /home/cvs/modperl-docs/src/docs/2.0/api/Apache/RequestRec.pod,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- RequestRec.pod	21 Sep 2004 13:58:03 -0000	1.32
  +++ RequestRec.pod	4 Oct 2004 02:15:49 -0000	1.33
  @@ -1180,7 +1180,7 @@
         my $bb = APR::Brigade->new($r->pool,
                                    $r->connection->bucket_alloc);
     
  -      my $b = APR::Bucket->new($data);
  +      my $b = APR::Bucket->new($bb->bucket_alloc, $data);
         $bb->insert_tail($b);
         $r->output_filters->fflush($bb);
         $bb->destroy;
  
  
  
  1.47      +5 -5      modperl-docs/src/docs/2.0/user/handlers/filters.pod
  
  Index: filters.pod
  ===================================================================
  RCS file: /home/cvs/modperl-docs/src/docs/2.0/user/handlers/filters.pod,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- filters.pod	15 Aug 2004 07:54:00 -0000	1.46
  +++ filters.pod	4 Oct 2004 02:15:49 -0000	1.47
  @@ -1535,7 +1535,7 @@
             warn("data: $data\n");
     
             if ($data and $data =~ s|^GET|HEAD|) {
  -              my $nb = APR::Bucket->new($data);
  +              my $nb = APR::Bucket->new($bb->bucket_alloc, $data);
                 $b->insert_after($nb);
                 $b->remove; # no longer needed
                 $f->ctx(1); # flag that that we have done the job
  @@ -1769,7 +1769,7 @@
             }
     
             my $len = $b->read(my $data);
  -          $b = APR::Bucket->new(lc $data) if $len;
  +          $b = APR::Bucket->new($bb->bucket_alloc, lc $data) if $len;
     
             $b->remove;
             $bb->insert_tail($b);
  @@ -2120,7 +2120,7 @@
             if ($b->read(my $data)) {
                 $data = join "",
                     map {scalar(reverse $_), "\n"} split "\n", $data;
  -              $b = APR::Bucket->new($data);
  +              $b = APR::Bucket->new($bb->bucket_alloc, $data);
             }
     
             $b->remove;
  @@ -2355,7 +2355,7 @@
         # in ctx
         for (split_buffer($buffer)) {
             if (length($_) == TOKEN_SIZE) {
  -              $bb->insert_tail(APR::Bucket->new($_));
  +              $bb->insert_tail(APR::Bucket->new($ba, $_));
             }
             else {
                 $ctx .= $_;
  @@ -2365,7 +2365,7 @@
         my $len = length($ctx);
         if ($seen_eos) {
             # flush the remainder
  -          $bb->insert_tail(APR::Bucket->new($ctx));
  +          $bb->insert_tail(APR::Bucket->new($ba, $ctx));
             $bb->insert_tail(APR::Bucket::eos_create($ba));
             warn "seen eos, flushing the remaining: $len bytes\n";
         }
  
  
  
  1.29      +3 -3      modperl-docs/src/docs/2.0/user/handlers/protocols.pod
  
  Index: protocols.pod
  ===================================================================
  RCS file: /home/cvs/modperl-docs/src/docs/2.0/user/handlers/protocols.pod,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- protocols.pod	15 Aug 2004 07:54:00 -0000	1.28
  +++ protocols.pod	4 Oct 2004 02:15:49 -0000	1.29
  @@ -366,7 +366,7 @@
                 if ($b->read(my $data)) {
                     $last++ if $data =~ /^[\r\n]+$/;
                     # could do some transformation on data here
  -                  $b = APR::Bucket->new($data);
  +                  $b = APR::Bucket->new($bb->bucket_alloc, $data);
                 }
     
                 $b->remove;
  @@ -469,7 +469,7 @@
     
                 if ($b->read(my $data)) {
                     last if $data =~ /^[\r\n]+$/;
  -                  my $nb = APR::Bucket->new(uc $data);
  +                  my $nb = APR::Bucket->new($bb->bucket_alloc, uc $data);
                     # head->...->$nb->$b ->...->tail
                     $b->insert_before($nb);
                     $b->remove;
  @@ -575,7 +575,7 @@
             last if $data =~ /^[\r\n]+$/;
     
             # could transform data here
  -          my $b = APR::Bucket->new($data);
  +          my $b = APR::Bucket->new($bb->bucket_alloc, $data);
             $bb->insert_tail($b);
     
             $c->output_filters->fflush($bb);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-cvs-unsubscribe@perl.apache.org
For additional commands, e-mail: docs-cvs-help@perl.apache.org


Mime
View raw message