stas        2004/08/14 23:30:51

  Modified:    t/filter/TestFilter out_bbs_basic.pm in_bbs_msg.pm
                        out_bbs_ctx.pm in_bbs_inject_header.pm
                        in_bbs_body.pm
  Log:
  use $b for bucket in all tests, to make it easier do global adjustements
  
  Revision  Changes    Path
  1.6       +6 -6      modperl-2.0/t/filter/TestFilter/out_bbs_basic.pm
  
  Index: out_bbs_basic.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/filter/TestFilter/out_bbs_basic.pm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -u -r1.5 -r1.6
  --- out_bbs_basic.pm  9 Jun 2004 14:46:21 -0000       1.5
  +++ out_bbs_basic.pm  15 Aug 2004 06:30:50 -0000      1.6
  @@ -29,19 +29,19 @@
           my $ba = $filter->r->connection->bucket_alloc;
   
           #should only have 1 bucket from the response() below
  -        for (my $bucket = $bb->first; $bucket; $bucket = $bb->next($bucket)) {
  -            ok $bucket->type->name;
  -            ok $bucket->length == 2;
  -            $bucket->read(my $data);
  +        for (my $b = $bb->first; $b; $b = $bb->next($b)) {
  +            ok $b->type->name;
  +            ok $b->length == 2;
  +            $b->read(my $data);
               ok (defined $data and $data eq 'ok');
           }
   
           my $tests = Apache::TestToString->finish;
   
           my $brigade = APR::Brigade->new($filter->r->pool, $ba);
  -        my $bucket = APR::Bucket->new($tests);
  +        my $b = APR::Bucket->new($tests);
   
  -        $brigade->insert_tail($bucket);
  +        $brigade->insert_tail($b);
   
           my $ok = $brigade->first->type->name =~ /mod_perl/ ? 4 : 0;
           $brigade->insert_tail(APR::Bucket->new("ok $ok\n"));
  
  
  
  1.11      +7 -7      modperl-2.0/t/filter/TestFilter/in_bbs_msg.pm
  
  Index: in_bbs_msg.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/filter/TestFilter/in_bbs_msg.pm,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -u -r1.10 -r1.11
  --- in_bbs_msg.pm     9 Jun 2004 14:46:21 -0000       1.10
  +++ in_bbs_msg.pm     15 Aug 2004 06:30:50 -0000      1.11
  @@ -28,22 +28,22 @@
       $filter->next->get_brigade($ctx_bb, $mode, $block, $readbytes);
   
       while (!$ctx_bb->is_empty) {
  -        my $bucket = $ctx_bb->first;
  +        my $b = $ctx_bb->first;
   
  -        $bucket->remove;
  +        $b->remove;
   
  -        if ($bucket->is_eos) {
  +        if ($b->is_eos) {
               debug "EOS!!!";
  -            $bb->insert_tail($bucket);
  +            $bb->insert_tail($b);
               last;
           }
   
  -        $bucket->read(my $data);
  +        $b->read(my $data);
           debug "FILTER READ:\n$data";
   
           if ($data and $data =~ s,GET $from_url,GET $to_url,) {
               debug "GET line rewritten to be:\n$data";
  -            $bucket = APR::Bucket->new($data);
  +            $b = APR::Bucket->new($data);
               # XXX: currently a bug in httpd doesn't allow to remove
               # the first connection filter. once it's fixed adjust the test
               # to test that it was invoked only once.
  @@ -51,7 +51,7 @@
               # $filter->remove; # this filter is no longer needed
           }
   
  -        $bb->insert_tail($bucket);
  +        $bb->insert_tail($b);
       }
   
       Apache::OK;
  
  
  
  1.7       +7 -7      modperl-2.0/t/filter/TestFilter/out_bbs_ctx.pm
  
  Index: out_bbs_ctx.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/filter/TestFilter/out_bbs_ctx.pm,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -u -r1.6 -r1.7
  --- out_bbs_ctx.pm    9 Jun 2004 14:46:21 -0000       1.6
  +++ out_bbs_ctx.pm    15 Aug 2004 06:30:50 -0000      1.7
  @@ -30,20 +30,20 @@
   
       my $data = exists $ctx->{data} ? $ctx->{data} : '';
   
  -    while (my $bucket = $bb->first) {
  -        $bucket->remove;
  +    while (my $b = $bb->first) {
  +        $b->remove;
   
  -        if ($bucket->is_eos) {
  +        if ($b->is_eos) {
               # flush the remainings and send a stats signature
               $bb_ctx->insert_tail(APR::Bucket->new("$data\n")) if $data;
               my $sig = join "\n", "received $ctx->{blocks} complete blocks",
                   "filter invoked $ctx->{invoked} times\n";
               $bb_ctx->insert_tail(APR::Bucket->new($sig));
  -            $bb_ctx->insert_tail($bucket);
  +            $bb_ctx->insert_tail($b);
               last;
           }
   
  -        if ($bucket->read(my $bdata)) {
  +        if ($b->read(my $bdata)) {
               $data .= $bdata;
               my $len = length $data;
   
  @@ -55,8 +55,8 @@
                   $ctx->{blocks} += $blocks;
               }
               if ($blocks) {
  -                $bucket = APR::Bucket->new("#" x $blocks);
  -                $bb_ctx->insert_tail($bucket);
  +                $b = APR::Bucket->new("#" x $blocks);
  +                $bb_ctx->insert_tail($b);
               }
           }
       }
  
  
  
  1.10      +14 -11    modperl-2.0/t/filter/TestFilter/in_bbs_inject_header.pm
  
  Index: in_bbs_inject_header.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/filter/TestFilter/in_bbs_inject_header.pm,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -u -r1.9 -r1.10
  --- in_bbs_inject_header.pm   9 Jun 2004 14:46:21 -0000       1.9
  +++ in_bbs_inject_header.pm   15 Aug 2004 06:30:50 -0000      1.10
  @@ -58,12 +58,12 @@
   
       return 0 unless @{ $ctx->{buckets} };
   
  -    my $bucket = shift @{ $ctx->{buckets} };
  -    $bb->insert_tail($bucket);
  +    my $b = shift @{ $ctx->{buckets} };
  +    $bb->insert_tail($b);
   
       if (1) {
           # extra debug, wasting cycles
  -        $bucket->read(my $data);
  +        $b->read(my $data);
           debug "injected header: [$data]";
       }
       else {
  @@ -156,17 +156,20 @@
       return $rv unless $rv == APR::SUCCESS;
   
       while (!$ctx_bb->is_empty) {
  -        my $bucket = $ctx_bb->first;
  +        my $b = $ctx_bb->first;
   
  -        $bucket->remove;
  -
  -        if ($bucket->is_eos) {
  +        if ($b->is_eos) {
               debug "EOS!!!";
  -            $bb->insert_tail($bucket);
  +            $b->remove;
  +            $bb->insert_tail($b);
               last;
           }
   
  -        $bucket->read(my $data);
  +        $b->read(my $data);
  +        # remove must happen after read, since it may cause split and
  +        # some new buckets inserted behind - if remove called too
  +        # early, those buckets will be lost
  +        $b->remove;
           debug "filter read:\n[$data]";
   
           # check that we really work only on the headers
  @@ -202,7 +205,7 @@
               # the separator header will be sent as a last header
               # so we send one newly added header and push the separator
               # to the end of the queue
  -            push @{ $ctx->{buckets} }, $bucket;
  +            push @{ $ctx->{buckets} }, $b;
               debug "queued header [$data]";
               inject_header_bucket($bb, $ctx);
               next; # inject_header_bucket already called insert_tail
  @@ -214,7 +217,7 @@
               # fall through
           }
   
  -        $bb->insert_tail($bucket);
  +        $bb->insert_tail($b);
       }
   
       return Apache::OK;
  
  
  
  1.7       +7 -7      modperl-2.0/t/filter/TestFilter/in_bbs_body.pm
  
  Index: in_bbs_body.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/filter/TestFilter/in_bbs_body.pm,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -u -r1.6 -r1.7
  --- in_bbs_body.pm    9 Jun 2004 14:46:21 -0000       1.6
  +++ in_bbs_body.pm    15 Aug 2004 06:30:51 -0000      1.7
  @@ -24,22 +24,22 @@
       $filter->next->get_brigade($ctx_bb, $mode, $block, $readbytes);
   
       while (!$ctx_bb->is_empty) {
  -        my $bucket = $ctx_bb->first;
  +        my $b = $ctx_bb->first;
   
  -        $bucket->remove;
  +        $b->remove;
   
  -        if ($bucket->is_eos) {
  +        if ($b->is_eos) {
               #warn "EOS!!!!";
  -            $bb->insert_tail($bucket);
  +            $bb->insert_tail($b);
               last;
           }
   
  -        if ($bucket->read(my $data)) {
  +        if ($b->read(my $data)) {
               #warn"[$data]\n";
  -            $bucket = APR::Bucket->new(scalar reverse $data);
  +            $b = APR::Bucket->new(scalar reverse $data);
           }
   
  -        $bb->insert_tail($bucket);
  +        $bb->insert_tail($b);
       }
   
       Apache::OK;
  
  
  

Reply via email to