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 http://apache.perl.org/docs/2.0/user/handlers/filters.html#Bucket_Brigade_based_Output_Filters: I think the order $b->remove must be before than $b = 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 = $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) = @_; my $bb_ctx = APR::Brigade->new($f->c->pool, $f->c->bucket_alloc); while (!$bb->is_empty) { my $b = $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 = APR::Bucket->new($bb->bucket_alloc,$data); $bb_ctx -> insert_tail($nb); } $b -> delete; } # $f->next->fflush($bb_ctx); my $rv = $f->next->pass_brigade($bb_ctx); return $rv unless $rv == 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 = $f->next->pass_brigade($bb_ctx); gives error. I've tried stupid changes like my $rv = $f->pass_brigade($bb_ctx); or my $rv = $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) = @_; my $b = $bb->first; my $np = 1; do { warn $b.' - '.$np; $np++; if ($b->is_eos) { $b = $bb->next($b); } else { $b->read(my $data); # $this->blogum_filter(\$data,$f->r,$f->c); my $nb = APR::Bucket->new($bb->bucket_alloc,$data); $b->insert_before($nb); $b->delete; $b = $bb->next($nb); } } while $b; return Apache::OK; } (similar code to http://perl.apache.org/docs/2.0/api/APR/Bucket.html#C_delete_) 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=SCALAR(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=SCALAR(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=SCALAR(0x111e0d8) - 1 at f:\tools\apache2/lib/perl/Blogum/BlogumFilter.pm line 49. APR::Bucket=SCALAR(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=SCALAR(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=SCALAR(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=SCALAR(0x11ea818) - 1 at f:\tools\apache2/lib/perl/Blogum/BlogumFilter.pm line 49. APR::Bucket=SCALAR(0x11ea7a0) - 2 at f:\tools\apache2/lib/perl/Blogum/BlogumFilter.pm line 49. APR::Bucket=SCALAR(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 => "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é 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