Re: $bb,$b, PerlOutputFilterHandler and $rv = $f->pass_brigade($bb);

[prev] [thread] [next] [Date index for 2004/12/18]

From: eps com estem
Subject: Re: $bb,$b, PerlOutputFilterHandler and $rv = $f->pass_brigade($bb);
Date: 19:38 on 18 Dec 2004
I've tested this another option:

------------------
sub handler : FilterRequestHandler
   {
   my($f, $bb) =3D @_;
   $bb->flatten(my $data);
   $bb->cleanup();
   $this->blogum_filter(\$data,$f->r,$f->c);
   my $bb_ctx =3D APR::Brigade->new($f->c->pool, $f->c->bucket_alloc);
   my $b =3D APR::Bucket->new($bb_ctx->bucket_alloc,$data);
   $bb_ctx -> insert_tail($b);
#  my $eos_b =3D APR::Bucket->eos_create($f->c->bucket_alloc);
#  $bb_ctx -> insert_tail($eos_b);
   $f->next->pass_brigade($bb_ctx);
   return Apache::OK;
   }
------------------

This option still makes the client wait for a final(?) response of the server, but
misteriously after 8-10 seconds the connection finishes and the firefox says 'Done'.

1)- First thing is that if i am creating a new bucket for a new brigade, the line
   my $b =3D APR::Bucket->new($bb->bucket_alloc,$data);
should be
   my $b =3D APR::Bucket->new($bb_ctx->bucket_alloc,$data);
or that's what i think(?). With this change in the first codes the situation however
doesn't change.

2)- Second thing is that, in a try to "finish" the transaction i wanted to create an eos
stream. Docs say
  use APR::Bucket ();
  use Apache::Connection ();
  my $ba =3D $c->bucket_alloc;
  my $eos_b =3D APR::Bucket::eos_create($ba);
so
  my $eos_b =3D APR::Bucket->eos_create($f->c->bucket_alloc);
should work ... or not ...
Error log says:
[Sat Dec 18 20:13:08 2004] [error] [client 127.0.0.1] Usage: APR::Bucket::eos_create(list)
at ...
If i put
  my $eos_b =3D APR::Bucket::eos_create($f->c->bucket_alloc);
there's no more Internal Error, but page appears (after 8-10 seconds) truncated.
a) :: is not equal to ->? i though yes but i have not verified
b) an eos ends only the brigade, isn't it? or it ends the filter?

3)- Third, i think $bb should be destroyed instead of cleaned up, am i right?




------------------
I tried as well the next:
$bb->flatten(my $data);
$bb->cleanup();
$this->blogum_filter(\$data,$f->r,$f->c);
my $b =3D APR::Bucket->new($bb_ctx->bucket_alloc,$data);
$bb -> insert_tail($b);
return Apache::OK;
------------------
Is this a valid alternative? Anyway this have not worked (client always waiting).

I have to note that the first option allows to see all the page altough the client is
still waiting, the other option waits without showing anything, it is why i say "it have
not worked".








>Hello.
>I want to add file-upload capacity to my program so i've installed libapreq2.
>Working with windows i've installed libapreq2 through ppm which install as a requisite
>mod_perl-dev 1.99_15, and 
>after i've installed 1.99_0.17 (the order is important, as version _17 is needed for some
>instructions i use).
>Version _18 is available, but i haven't found any repositories. (In addition libapreq2
>seemed to not to be present 
>with the order "search libapreq" that gave only version 1.2, but libapreq2 was present
>when browsing through the 
>repositories through html pages so the order "install libapreq2" worked.
>But prior to using the new Request and Upload modules i needed to change my "old" code to
>be compatible with _17 
>version.
>My problem is with those brigades full of buckets.
>1)
>Document
><a
href=3D"/app/message?l=3Des&o=3D8&url=3Dhttp%3A%2F%2Fapache%2Eperl%2Eorg%2Fdocs%2F2%2E0%2Fuser%2Fhandlers%2Ffilters%2Ehtml%23Bucket%5FBrigade%5Fbased%5FOutput%5FFilters%3A"
target=3D"_blank">http://apache.perl.org/docs/2.0/user/handlers/filters.html#Bucket_Brigade_based_Output_Filters:</a>;
>I think the order $b->remove must be before than $b =3D APR:Bucket...new.
>If not the bucket is not removed and the brigade never is emptied (i think).
>2)
>I have problems with the order
>my $rv =3D $f->next->pass_brigade($bb_ctx);
>If i comment this line the process (server-client communication) finishes (status bar
>presents a 'done' mesage).
>If i uncomment the line the communication hangs up and after a while apache crashes (with
>windows window alerting 
>this, and with a restarting order in error log).
>After trying with the code, my final filter is this:
>---------------------
>sub handler : FilterRequestHandler
>   {
>   my($f, $bb) =3D @_;
>   my $bb_ctx =3D APR::Brigade->new($f->c->pool, $f->c->bucket_alloc);
>   while (!$bb->is_empty)
>      {
>      my $b =3D $bb->first;
>      if ($b->is_eos)
>         {
>         $bb_ctx -> insert_tail($b);
>         last;
>         }
>      if ($b->read(my $data))
>         {
>#        $this -> blogum_filter(\$data,$f->r,$f->c);
>         my $nb =3D APR::Bucket->new($bb->bucket_alloc,$data);
>         $bb_ctx -> insert_tail($nb);
>         }
>      $b -> delete;
>      }
>#  $f->next->fflush($bb_ctx);
>   my $rv =3D $f->next->pass_brigade($bb_ctx);
>   return $rv unless $rv =3D=3D APR::SUCCESS;
>   return Apache::OK;
>   }
>---------------------
>The first commented line reffers to my alteration of $data.
>I've changed the "->remove" method for the "->delete", as it is indicated in docs that the
>bucked removed must be 
>also destroyed to avoid a memory leak.
>(If it is true, then the document before should be changed as well).
>Anyway i've been unable to find why my $rv =3D $f->next->pass_brigade($bb_ctx); gives error.
>I've tried stupid changes like
> my $rv =3D $f->pass_brigade($bb_ctx);
>or
> my $rv =3D $f->pass_brigade($bb);
>They didn't complain so the problem seems to be with $f->next.
>Alternatively i've also tried the seccond commented line (fflush), that uses the same
>"pass_brigade" function. The 
>result is the same (client waiting forever until i stop the restarted apache).
>Finally, before asking here (one never knows how ignorant he is) i've tried the next
>alternative code:
>sub handler : FilterRequestHandler
>   {
>   my($f, $bb) =3D @_;
>   my $b =3D $bb->first;
>   my $np =3D 1;
>   do
>      {
>      warn $b.' - '.$np;
>      $np++;
>      if ($b->is_eos)
>         {
>         $b =3D $bb->next($b);
>      } else {
>         $b->read(my $data);
>#        $this->blogum_filter(\$data,$f->r,$f->c);
>         my $nb =3D APR::Bucket->new($bb->bucket_alloc,$data);
>         $b->insert_before($nb);
>         $b->delete;
>         $b =3D $bb->next($nb);
>         }
>   } while $b;
>   return Apache::OK;
>   }
>(similar code to <a
href=3D"/app/message?l=3Des&o=3D8&url=3Dhttp%3A%2F%2Fperl%2Eapache%2Eorg%2Fdocs%2F2%2E0%2Fapi%2FAPR%2FBucket%2Ehtml%23C%5Fdelete%5F%29"
target=3D"_blank">http://perl.apache.org/docs/2.0/api/APR/Bucket.html#C_delete_)</a>;
>This code produces an Internal Server Error. After only an 1)init apache 2)firefox
>petition and 3)stopping apache, 
>the error log shows this.
>[Sat Dec 18 16:57:22 2004] [notice] Parent: Created child process 3076
>some warnings of my code
>[Sat Dec 18 16:57:23 2004] [notice] Child 3076: Child process is running
>[Sat Dec 18 16:57:23 2004] [notice] Child 3076: Acquired the start mutex.
>[Sat Dec 18 16:57:23 2004] [notice] Child 3076: Starting 250 worker threads.
>APR::Bucket=3DSCALAR(0x111e0e4) - 1 at f:\tools\apache2/lib/perl/Blogum/BlogumFilter.pm
line 49.
>Use of uninitialized value in split at f:\tools\apache2/lib/perl/Blogum/News/Database.pm
>line 27.
>APR::Bucket=3DSCALAR(0x111e0e4) - 1 at f:\tools\apache2/lib/perl/Blogum/BlogumFilter.pm
line 49.
>Use of uninitialized value in split at f:\tools\apache2/lib/perl/Blogum/Generic.pm line 102.
>APR::Bucket=3DSCALAR(0x111e0d8) - 1 at f:\tools\apache2/lib/perl/Blogum/BlogumFilter.pm
line 49.
>APR::Bucket=3DSCALAR(0x111e0e4) - 2 at f:\tools\apache2/lib/perl/Blogum/BlogumFilter.pm
line 49.
>[Sat Dec 18 16:57:39 2004] [notice] Parent: Received shutdown signal -- Shutting down the
>server.
>[Sat Dec 18 16:57:39 2004] [notice] Child 3076: Exit event signaled. Child process is ending.
>[Sat Dec 18 16:57:40 2004] [notice] Child 3076: Released the start mutex
>[Sat Dec 18 16:57:41 2004] [notice] Child 3076: Waiting for 250 worker threads to exit.
>[Sat Dec 18 16:57:41 2004] [notice] Child 3076: All worker threads have exited.
>[Sat Dec 18 16:57:41 2004] [notice] Child 3076: Child process is exiting
>[Sat Dec 18 16:57:41 2004] [notice] Parent: Child process exited successfully.
>>From this, do(?) i have to understand that:
>- There are three brigades
>- First brigade have one bucket
>- Second brigade has one bucket, and it is the same that the prior brigade (really?)
>- Third brigade has two different buckets (the second probably the eos?)
>- There is no log-reason fot the interval server error, but the warning of the first two
>buckets is not present at 
>the last brigade, so the program is stopped before.
>My numbers (Win XP)
>Apache/2.0.48 (Win32) mod_perl/1.99_17 Perl/v5.8.2
>Apache is old, so i install 2.0.52. Repeating this the error log changes a little:
>APR::Bucket=3DSCALAR(0x11ea824) - 1 at f:\tools\apache2/lib/perl/Blogum/BlogumFilter.pm
line 49.
>Use of uninitialized value in split at f:\tools\apache2/lib/perl/Blogum/News/Database.pm
>line 27.
>APR::Bucket=3DSCALAR(0x11ea824) - 1 at f:\tools\apache2/lib/perl/Blogum/BlogumFilter.pm
line 49.
>Use of uninitialized value in split at f:\tools\apache2/lib/perl/Blogum/Generic.pm line 102.
>APR::Bucket=3DSCALAR(0x11ea818) - 1 at f:\tools\apache2/lib/perl/Blogum/BlogumFilter.pm
line 49.
>APR::Bucket=3DSCALAR(0x11ea7a0) - 2 at f:\tools\apache2/lib/perl/Blogum/BlogumFilter.pm
line 49.
>APR::Bucket=3DSCALAR(0x11ea818) - 3 at f:\tools\apache2/lib/perl/Blogum/BlogumFilter.pm
line 49.
>The same conclusions but now with a third bucket in the last brigade, that is the same
>first bucket than before?
>And repeating the first code the results were the same, an apache crash with the log
>message of
>[Sat Dec 18 17:35:52 2004] [notice] Parent: child process exited with status 3221225477 --
>Restarting.
>One last change: Moving the PerlOutputFilterHandler =3D> "Blogum::BlogumFilter" from start
>pl script to httpd.conf 
>doesn't make any difference.
>Finally, a ppm of mod_perl _18 seems to be still not available, but the change log doesn't
>indicate (i think) any 
>change applied to this, so i think that upgrade would not solve this.
>Thanks.
>---------------------------------------------------------
>Esta Navidad, s=E9 m=E1s original =BFTe atreves a enviar una postal con tu voz? <a
href=3D"/app/message?l=3Des&o=3D8&url=3Dhttp%3A%2F%2Fgreetingmania%2Eya%2Ecom"
target=3D"_blank">http://greetingmania.ya.com</a>;
>Ya.com ADSL Router Wi-Fi: S=F3lo 29,90 =80/mes + IVA*. Router + Antivirus y firewall =A1Gratis!
<a href=3D"/app/message?l=3Des&o=3D8&url=3Dhttp%3A%2F%2Facceso%2Eya%2Ecom%2Fadsl%2F256router"
target=3D"_blank">http://acceso.ya.com/adsl/256router</a>;
>-- 
>Report problems: <a
href=3D"/app/message?l=3Des&o=3D8&url=3Dhttp%3A%2F%2Fperl%2Eapache%2Eorg%2Fbugs%2F"
target=3D"_blank">http://perl.apache.org/bugs/</a>;
>Mail list info: <a
href=3D"/app/message?l=3Des&o=3D8&url=3Dhttp%3A%2F%2Fperl%2Eapache%2Eorg%2Fmaillist%2Fmodperl%2Ehtml"
target=3D"_blank">http://perl.apache.org/maillist/modperl.html</a>;
>List etiquette: <a
href=3D"/app/message?l=3Des&o=3D8&url=3Dhttp%3A%2F%2Fperl%2Eapache%2Eorg%2Fmaillist%2Femail%2Detiquette%2Ehtml"
target=3D"_blank">http://perl.apache.org/maillist/email-etiquette.html</a>;
---------------------------------------------------------
Esta Navidad, sé más original ¿Te atreves a enviar una postal con tu voz? http://greetingmania.ya.com
Ya.com ADSL Router Wi-Fi: Sólo 29,90 €/mes + IVA*. Router + Antivirus y firewall ¡Gratis! http://acceso.ya.com/adsl/256router

        -- 
        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

Re: $bb,$b, PerlOutputFilterHandler and $rv = $f->pass_brigade($bb);
eps com estem 19:38 on 18 Dec 2004

Generated at 11:26 on 21 Dec 2004 by mariachi v0.52