perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dorian taylor <>
Subject Re: ap_save_brigade
Date Mon, 22 Jul 2013 09:08:10 GMT
OK, I have a clue why ap_save_brigade wasn't implemented. I looked at
its source and it basically does this:

sub Apache2::Filter::save_brigade {
    my ($f, $saveto, $bb, $pool) = @_;
    # XXX should this be $f->r->pool?
    $pool ||= $f->c->pool;

    my $ret = APR::Const::SUCCESS;

    for (my $b = $bb->first; !$b->is_eos; $b = $bb->next($b)) {
        my $rv = $b->setaside($pool);

        if ($rv == APR::Const::ENOTIMPL) {
            my $len = $b->read(my $data);
            # apparently this changes the bucket type?
            $rv = $b->setaside($pool) if $len;

        # check for some other kind of error
        if ($rv != APR::Const::SUCCESS) {
            $ret = $rv;
            return $rv if $rv != APR::Const::ENOTIMPL;

    # now concatenate the brigade to the target

    return $ret;

The difference in the C version is that saveto and bb are pointers to
pointers to brigades, so if saveto is NULL, ap_save_brigade creates
one, which would be kind of icky for a Perl interface. It also means
that patch I submitted in 2005 was probably broken anyway.

There's really no reason why it couldn't be implemented in mod_perl in
a way that stipulates passing a target brigade in as input though. I'm
pretty sure it'd be a heck of a lot more efficient than that
subroutine I just wrote above.

On Mon, Jul 22, 2013 at 12:14 AM, dorian taylor
<> wrote:
> Hello,
> Is there a reason why ap_save_brigade hasn't been implemented? Does it
> have special needs?
> (Funnily, after googling this issue, I found I had asked the same
> question in 2005:
> —and apparently written a patch.)
> Cheers,
> --
> Dorian Taylor

Dorian Taylor

View raw message