httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cliff Woolley <cliffwool...@yahoo.com>
Subject Re: [PATCH] Take 3 of httpd filter rewrite...
Date Wed, 26 Sep 2001 09:09:58 GMT
On Wed, 26 Sep 2001, Greg Stein wrote:

> Um. The above loop sucks. ctx->b is *only* a SOCKET bucket. We know that as
> a given since that is a private brigade that we populated. Further, the
> above loop will read *everything* on that socket into memory. Man... talk
> about Denial of Service. "Hey! Apache! Take this gigabyte of data!"
>
> Okay... so we drop yet another comment about a hack. But while we're leaving
> hacks around here, you may as well toss the loop. apr_brigade_length() is
> going to do exactly the same thing -- the loop is redundant. Just do the
> CONCAT after calling length()

Yep.  (:-/)

> > +        apr_brigade_partition(ctx->b, *readbytes, &e);
> > +        /* Must do split before CONCAT */
> > +        if (e != APR_BRIGADE_SENTINEL(ctx->b)) {
> > +            newbb = apr_brigade_split(ctx->b, e);
> > +        }
>
> This feels like our APIs are wrong. We really ought to be able to partition
> then split. Checking for the sentinel seems like too much "inside
> knowledge." The split() ought to be able to assume a sentinel means "no
> splitting".

It already does.


APU_DECLARE(apr_bucket_brigade *) apr_brigade_split(apr_bucket_brigade *b,
						 apr_bucket *e)
{
    apr_bucket_brigade *a;
    apr_bucket *f;

    a = apr_brigade_create(b->p);
    /* Return an empty brigade if there is nothing left in
     * the first brigade to split off
     */
    if (e != APR_BRIGADE_SENTINEL(b)) {
        f = APR_RING_LAST(&b->list);
        APR_RING_UNSPLICE(e, f, link);
        APR_RING_SPLICE_HEAD(&a->list, e, f, apr_bucket, link);
    }
    return a;
}

--Cliff


--------------------------------------------------------------
   Cliff Woolley
   cliffwoolley@yahoo.com
   Charlottesville, VA



Mime
View raw message