httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip M. Gollucci" <pgollu...@p6m7g8.com>
Subject Re: Endless loop in split_on_bdry() of library/parser_multipart.c?
Date Sun, 04 Jun 2006 08:02:26 GMT
Joe Orton wrote:
> A loop like this will not terminate if "e" points to the brigade 
> sentinel on entry; not sure if this is possible in the context of this 
> code, but it's easy enough to verify with an assertion.
         else if (off > 0) {
             /* prior (partial) strncmp failed,
              * so we can move previous buckets across
              * and retest buf against the full bdry.
              */
           #include <assert.h>
           assert(e != APR_BRIGADE_SENTINEL(in));

             do {
                 apr_bucket *f = APR_BRIGADE_FIRST(in);
                 APR_BUCKET_REMOVE(f);
                 APR_BRIGADE_INSERT_TAIL(out, f);
             } while (e != APR_BRIGADE_FIRST(in));

             off = 0;
             goto look_for_boundary_up_front;
         }

Apparently that never happens ... at least in the cases the tests throw 
at it.

> If all you want to do is move a section of buckets onto another brigade 
> you can actually do it in a constant time operation, i.e. without having 
> to iterate through all the buckets.  To splice buckets from "a" to "b" 
> inclusively onto brigade "output", do:
> 
>    APR_RING_UNSPLICE(a, b, link);
>    APR_RING_SPLICE_TAIL(&output->list, a, b, apr_bucket, link);
> 
> and APR_RING_SPLICE_HEAD can be used similarly.  It's a good idea to use 
> the _CHECK_CONSISTENCY macros after using any APR_RING_* macros directly 
> so that debug builds run the sanity checks.
Apparently, I'm missing some knowlege.  Aren't brigades implemented as 
rings.  Can you safely mix the use of the macros?  APREQ used the
brigade versions throughout.

           apr_bucket *f = APR_RING_FIRST(&in->list);
           apr_bucket *l = APR_RING_LAST(&in->list);

           APR_RING_UNSPLICE(f, l, link);
           APR_RING_SPLICE_TAIL(&out->list, f, l, apr_bucket, link);

           APR_BRIGADE_CHECK_CONSISTENCY(f);
           APR_BRIGADE_CHECK_CONSISTENCY(l);

doesn't quite work, but I'm still adjusting to the API and need to read up.


-- 
------------------------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 323.219.4708
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Software Engineer - TicketMaster - http://ticketmaster.com
1024D/A79997FA F357 0FDD 2301 6296 690F  6A47 D55A 7172 A799 97F

"It takes a minute to have a crush on someone, an hour to like someone,
and a day to love someone, but it takes a lifetime to forget someone..."

Mime
View raw message