Thanks Philippe,

It's now no longer failing, however the input filter is not returning any
data and I get the following error in error_log:

-e: Deep recursion on subroutine "ZCRM::OFilter::input" at
/opt/code/CRM/OFilter.pm line 42.

Here's the subroutine:

sub input {
    my $f = shift;
    my $r = $f->r;

    my $bb = APR::Brigade->new( $r->pool, $r->connection->bucket_alloc );

    my $data     = '';
    my $seen_eos = 0;
    do {
        $r->input_filters->get_brigade( $bb, Apache2::Const::MODE_READBYTES,
            APR::Const::BLOCK_READ, IOBUFSIZE );

        for ( my $b = $bb->first ; $b ; $b = $bb->next($b) ) {
            if ( $b->is_eos ) {
                $seen_eos++;
                last;
            }

            if ( $b->read( my $buf ) ) {
                $data .= $buf;
            }

            $b->remove;    # optimization to reuse memory
        }
    } while ( !$seen_eos );

    $bb->destroy;

    return $data;
}


On Mon, Jun 20, 2016 at 1:49 AM, Philippe Chiasson <go...@ectoplasm.org>
wrote:

>
>
> Sent from my iPhone
>
> On Jun 19, 2016, at 19:10, Henry Combrinck <henrylcombri...@gmail.com>
> wrote:
>
> Greetings,
>
> I'm relatively new to mod_perl, so please forgive the ignorance.
>
> I've managed to create an output filter, but I'm having a problem with an
> input filter.  The error I get is as per the subject line.
>
> Here's the code:
>
> apache config
>
> Perlrequire /opt/code/scripts/apache2-perl-startup.pl
> ...
> PerlOutputFilterHandler ZCRM::OFilter::output
> PerlInputFilterHandler ZCRM::OFilter::input
>
> And here's the perl code (output filter works fine, but the input filter 
> results in the error below)
>
> package ZCRM::OFilter;
>
> use strict;
> use warnings;
>
> use Apache2::Filter     ();
> use Apache2::RequestRec ();
> use Apache2::Const -compile => qw(OK DECLINED MODE_READBYTES);
> use APR::Const -compile => qw(SUCCESS BLOCK_READ);
> use Apache2::Connection ();
>
> use constant IOBUFSIZE  => 8192;
>
> use strict;
>
> sub output {
>     my $f = shift;
>     my $r = $f->r;
>
>     while ( $f->read( my $buffer, 1024 ) ) {
>         # do work on $buffer...
>         $f->print($buffer);
>     }
>
>     return Apache2::Const::OK;
> }
>
> sub input {
>     my $r = shift;
>
> my $f = shift;
> my $r = $f->r;
>
> Just like in the output filter example above.
>
>
>     my $bb = APR::Brigade->new( $r->pool, $r->connection->bucket_alloc);  # 
> <--- Line XX - ERROR here
>
>     my $data     = '';
>     my $seen_eos = 0;
>     do {
>         $r->input_filters->get_brigade( $bb, Apache2::Const::MODE_READBYTES,
>             APR::Const::BLOCK_READ, IOBUFSIZE );
>
>         for ( my $b = $bb->first ; $b ; $b = $bb->next($b)) {
>             if ( $b->is_eos ) {
>                 $seen_eos++;
>                 last;
>             }
>
>             if ( $b->read( my $buf ) ) {
>                 $data .= $buf;
>             }
>
>             $b->remove;    # optimization to reuse memory
>         }
>     } while ( !$seen_eos );
>
>     $bb->destroy;
>
>     return $data;
> }
>
> 1;
>
> I would appreciate any pointers.
>
> Thanks
> Henk
>
>

Reply via email to