stas        2004/06/10 08:02:21

  Modified:    src/docs/2.0/api/APR Error.pod
               src/docs/2.0/user/handlers filters.pod http.pod
                        protocols.pod
  Log:
  tweaks
  
  Revision  Changes    Path
  1.7       +27 -10    modperl-docs/src/docs/2.0/api/APR/Error.pod
  
  Index: Error.pod
  ===================================================================
  RCS file: /home/cvs/modperl-docs/src/docs/2.0/api/APR/Error.pod,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -u -r1.6 -r1.7
  --- Error.pod 9 Jun 2004 16:17:42 -0000       1.6
  +++ Error.pod 10 Jun 2004 15:02:21 -0000      1.7
  @@ -21,7 +21,7 @@
   C<APR::Error> handles APR/Apache/mod_perl exceptions for you, while
   leaving you in control.
   
  -Apache and APR API return status code for almost all methods, so if
  +Apache and APR API return a status code for almost all methods, so if
   you didn't check the return code and handled any possible problems,
   you may have silent failures which may cause all kind of obscure
   problems. On the other hand checking the status code after each call
  @@ -50,7 +50,7 @@
   where that function was invoked from. More attributes could be added
   in the future.
   
  -C<APR::Error> uses method overloading, such that in boolean and
  +C<APR::Error> uses Perl operator overloading, such that in boolean and
   numerical contexts, the object returns the status code; in the string
   context the full error message is returned.
   
  @@ -93,27 +93,44 @@
     warn "read $rlen bytes\n";
   
   and in certain cases it times out. The code will die and log the
  -reason for the failure, which is fine, but later on you decide that
  -you want to give the read another chance before dying. In which case
  -you rewrite the code to handle the exception like so:
  +reason for the failure, which is fine, but later on you may decide
  +that you want to have another attempt to read before dying. In which
  +case you rewrite the code to handle the exception like this:
   
     use APR::Const -compile => qw(TIMEUP);
     my $buff;
  -  retry:
  -  my $rlen = eval { $sock->recv($buff, 1024) };
  +  my $tries = 0;
  +  RETRY: my $rlen = eval { $sock->recv($buff, 1024) };
     if ($@) {
  -     die $@ unless ref $@ && $@ == APR::TIMEUP;
  -     goto retry;
  +      die $@ unless ref $@ && $@ == APR::TIMEUP;
  +      goto RETRY if $tries++ < 3;
     }
     warn "read $rlen bytes\n";
   
   Notice that we handle non-object and non-C<APR::Error> exceptions as
   well, by simply rethrowing them.
   
  +You certainly want to have a limit on how many times the code retries
  +the operation as in this example and you probably want to add some
  +fine grained sleep time between attempts, which can be achieved with
  +C<select>. As a result the retry code may look like this:
  +
  +  use APR::Const -compile => qw(TIMEUP);
  +  my $tries = 0;
  +  RETRY: my $rlen = eval { $sock->recv($buff, 1024) };
  +  if ($@) {
  +      die $@ unless ref $@ && $@ == APR::TIMEUP;
  +      if ($tries++ < 3) {
  +          # sleep 250msec
  +          select undef, undef, undef, 0.25;
  +          goto RETRY;
  +      }
  +  }
  +  warn "read $rlen bytes\n";
   
   Finally, the class is called C<APR::Error> because it needs to be used
   outside mod_perl as well, when called from
  -C<L<APR|docs::2.0::api::APR>> applications written in perl.
  +C<L<APR|docs::2.0::api::APR>> applications written in Perl.
   
   
   =head1 API
  
  
  
  1.45      +8 -8      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.44
  retrieving revision 1.45
  diff -u -u -r1.44 -r1.45
  --- filters.pod       9 Jun 2004 16:17:42 -0000       1.44
  +++ filters.pod       10 Jun 2004 15:02:21 -0000      1.45
  @@ -2112,22 +2112,22 @@
         my $bb_ctx = APR::Brigade->new($f->c->pool, $f->c->bucket_alloc);
     
         while (!$bb->is_empty) {
  -          my $bucket = $bb->first;
  +          my $b = $bb->first;
     
  -          $bucket->remove;
  +          $b->remove;
     
  -          if ($bucket->is_eos) {
  -              $bb_ctx->insert_tail($bucket);
  +          if ($b->is_eos) {
  +              $bb_ctx->insert_tail($b);
                 last;
             }
     
  -          if ($bucket->read(my $data)) {
  +          if ($b->read(my $data)) {
                 $data = join "",
                     map {scalar(reverse $_), "\n"} split "\n", $data;
  -              $bucket = APR::Bucket->new($data);
  +              $b = APR::Bucket->new($data);
             }
     
  -          $bb_ctx->insert_tail($bucket);
  +          $bb_ctx->insert_tail($b);
         }
     
         my $rv = $f->next->pass_brigade($bb_ctx);
  @@ -2719,7 +2719,7 @@
   the read from the file can be postponed to the very moment when the
   data is sent to the client, thus saving a lot of memory and CPU
   cycles.  though filters writers should be aware that if they call
  -$bucket-E<gt>read(), or any other operation that internally forces the
  +$b-E<gt>read(), or any other operation that internally forces the
   bucket to read the information into the memory (like the length() op)
   and thus making the data handling inefficient. therefore a care should
   be taken so not to read the data in, unless it's really necessary.
  
  
  
  1.36      +1 -1      modperl-docs/src/docs/2.0/user/handlers/http.pod
  
  Index: http.pod
  ===================================================================
  RCS file: /home/cvs/modperl-docs/src/docs/2.0/user/handlers/http.pod,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -u -r1.35 -r1.36
  --- http.pod  9 Jun 2004 17:06:55 -0000       1.35
  +++ http.pod  10 Jun 2004 15:02:21 -0000      1.36
  @@ -314,7 +314,7 @@
   =head2 PerlMapToStorageHandler
   
   The I<map_to_storage> phase is used to perform the translation of a
  -request's URI into an corresponding filename. If no custom handler is
  +request's URI into a corresponding filename. If no custom handler is
   provided, the server will try to walk the filesystem trying to find
   what file or directory corresponds to the request's URI. Since usually
   mod_perl handler don't have corresponding files on the filesystem, you
  
  
  
  1.24      +14 -14    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.23
  retrieving revision 1.24
  diff -u -u -r1.23 -r1.24
  --- protocols.pod     9 Jun 2004 16:17:42 -0000       1.23
  +++ protocols.pod     10 Jun 2004 15:02:21 -0000      1.24
  @@ -361,22 +361,22 @@
             last if $bb_in->is_empty;
     
             while (!$bb_in->is_empty) {
  -              my $bucket = $bb_in->first;
  +              my $b = $bb_in->first;
     
  -              $bucket->remove;
  +              $b->remove;
     
  -              if ($bucket->is_eos) {
  -                  $bb_out->insert_tail($bucket);
  +              if ($b->is_eos) {
  +                  $bb_out->insert_tail($b);
                     last;
                 }
     
  -              if ($bucket->read(my $data)) {
  +              if ($b->read(my $data)) {
                     $last++ if $data =~ /^[\r\n]+$/;
                     # could do some transformation on data here
  -                  $bucket = APR::Bucket->new($data);
  +                  $b = APR::Bucket->new($data);
                 }
     
  -              $bb_out->insert_tail($bucket);
  +              $bb_out->insert_tail($b);
             }
     
             my $fb = APR::Bucket::flush_create($c->bucket_alloc);
  @@ -411,12 +411,12 @@
   represented by the following pseudo-code:
   
     while ($bb_in = get_brigade()) {
  -      while ($bucket_in = $bb_in->get_bucket()) {
  -          $bucket_in->read(my $data);
  +      while ($b_in = $bb_in->get_bucket()) {
  +          $b_in->read(my $data);
             # do something with data
  -          $bucket_out = new_bucket($data);
  +          $b_out = new_bucket($data);
     
  -          $bb_out->insert_tail($bucket_out);
  +          $bb_out->insert_tail($b_out);
         }
         $bb_out->insert_tail($flush_bucket);
         pass_brigade($bb_out);
  @@ -443,7 +443,7 @@
   
   with just one line:
   
  -          $c->output_fiilters->fflush($bb_out);
  +          $c->output_filters->fflush($bb_out);
   
   If you look at the complete handler, the loop is terminated when one
   of the following conditions occurs: an error happens, the end of
  @@ -538,8 +538,8 @@
             last if $data =~ /^[\r\n]+$/;
     
             # could transform data here
  -          my $bucket = APR::Bucket->new($data);
  -          $bb->insert_tail($bucket);
  +          my $b = APR::Bucket->new($data);
  +          $bb->insert_tail($b);
     
             $c->output_filters->fflush($bb);
         }
  
  
  

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

Reply via email to