Re: ap_save_brigade

dorian taylor <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CAMrqWm3GLkP9hVYGEys28n4EwW6=wnMXRUvWzGT_xwEMfHx6Gw@mail.gmail.com>
OK, I have a clue why ap_save_brigade wasn't implemented. I looked at
its source and it basically does this:

# XXX UNTESTED CODE
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
    $saveto->concat($bb);

    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
<[email protected]> 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:
> http://mail-archives.apache.org/mod_mbox/perl-modperl/200505.mbox/%[email protected]%3E
> —and apparently written a patch.)
>
> Cheers,
>
> --
> Dorian Taylor
> http://doriantaylor.com/



-- 
Dorian Taylor
http://doriantaylor.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.