httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwool...@apache.org
Subject cvs commit: httpd-2.0/modules/filters mod_include.c
Date Sat, 21 Apr 2001 22:01:05 GMT
jwoolley    01/04/21 15:01:05

  Modified:    modules/filters mod_include.c
  Log:
  Revert about half of the last commit because of an oversight on my part
  that broke it.  Unfortunately, fixing the oversight "the right way" is
  almost as ugly as the original code; it's easier to just go back to the way
  it was, at least for now.
  
  The problem is that the original code would delete buckets from foo through
  bar in the brigade, and the patched code deletes *everything* up through
  bar, which is bad.  I could have fixed it by doing two splits, but that
  introduces too many palloc's for my taste.  It's also fixable with RING macros,
  but I refuse to start using RING macros directly on brigades.  The best
  solution would be if there were a brigade equivalent to a RING_UNSPLICE/
  RING_INSERT_HEAD sequence (this sequence is also used interally by
  apr_brigade_split(), btw), something like this:
  APR_BRIGADE_TRANSFER_BUCKETS(oldbrigade,newbrigade,startbucket,endbucket);
  
  Absent that, the affected parts of the patch are hereby reverted (grumble,
  grumble).  If people liek the APR_BRIGADE_TRANSFER_BUCKETS() idea, I'll
  implement that and repatch mod_include later.
  
  Revision  Changes    Path
  1.109     +29 -13    httpd-2.0/modules/filters/mod_include.c
  
  Index: mod_include.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/filters/mod_include.c,v
  retrieving revision 1.108
  retrieving revision 1.109
  diff -u -d -u -r1.108 -r1.109
  --- mod_include.c	2001/04/20 20:58:28	1.108
  +++ mod_include.c	2001/04/21 22:01:05	1.109
  @@ -2387,11 +2387,15 @@
               /* If I am inside a conditional (if, elif, else) that is false
                *   then I need to throw away anything contained in it.
                */
  -            if ((!(ctx->flags & FLAG_PRINTING)) && (tmp_dptr != NULL)) {
  -                apr_bucket_brigade *temp_bb = *bb;
  -                *bb = apr_brigade_split(temp_bb, tmp_dptr);
  -                apr_brigade_destroy(temp_bb);
  -                dptr = APR_BRIGADE_FIRST(*bb);
  +            if ((!(ctx->flags & FLAG_PRINTING)) && (tmp_dptr != NULL) &&
  +                (dptr != APR_BRIGADE_SENTINEL(*bb))) {
  +                while ((dptr != APR_BRIGADE_SENTINEL(*bb)) &&
  +                       (dptr != tmp_dptr)) {
  +                    apr_bucket *free_bucket = dptr;
  +
  +                    dptr = APR_BUCKET_NEXT (dptr);
  +                    apr_bucket_delete(free_bucket);
  +                }
               }
   
               /* Adjust the current bucket position based on what was found... */
  @@ -2471,13 +2475,17 @@
                   CREATE_ERROR_BUCKET(ctx, tmp_bkt, dptr, content_head);
   
                   /* DO CLEANUP HERE!!!!! */
  +                tmp_dptr = ctx->head_start_bucket;
                   if (!APR_BRIGADE_EMPTY(ctx->ssi_tag_brigade)) {
                       apr_brigade_cleanup(ctx->ssi_tag_brigade);
                   }
                   else {
  -                    apr_bucket_brigade *temp_bb = *bb;
  -                    *bb = apr_brigade_split(temp_bb, dptr);
  -                    apr_brigade_destroy(temp_bb);
  +                    do {
  +                        tmp_bkt  = tmp_dptr;
  +                        tmp_dptr = APR_BUCKET_NEXT (tmp_dptr);
  +                        apr_bucket_delete(tmp_bkt);
  +                    } while ((tmp_dptr != dptr) &&
  +                             (tmp_dptr != APR_BRIGADE_SENTINEL(*bb)));
                   }
   
                   return;
  @@ -2535,13 +2543,17 @@
               if (content_head == NULL) {
                   content_head = dptr;
               }
  +            tmp_dptr = ctx->head_start_bucket;
               if (!APR_BRIGADE_EMPTY(ctx->ssi_tag_brigade)) {
                   apr_brigade_cleanup(ctx->ssi_tag_brigade);
               }
               else {
  -                apr_bucket_brigade *temp_bb = *bb;
  -                *bb = apr_brigade_split(temp_bb, content_head);
  -                apr_brigade_destroy(temp_bb);
  +                do {
  +                    tmp_bkt  = tmp_dptr;
  +                    tmp_dptr = APR_BUCKET_NEXT (tmp_dptr);
  +                    apr_bucket_delete(tmp_bkt);
  +                } while ((tmp_dptr != content_head) &&
  +                         (tmp_dptr != APR_BRIGADE_SENTINEL(*bb)));
               }
               if (ctx->combined_tag == tmp_buf) {
                   memset (ctx->combined_tag, '\0', ctx->tag_length);
  @@ -2578,8 +2590,12 @@
           /* Inside a false conditional (if, elif, else), so toss it all... */
           if ((dptr != APR_BRIGADE_SENTINEL(*bb)) &&
               (!(ctx->flags & FLAG_PRINTING))) {
  -            apr_brigade_cleanup(*bb);
  -            dptr = APR_BRIGADE_SENTINEL(*bb);
  +            apr_bucket *free_bucket;
  +            do {
  +                free_bucket = dptr;
  +                dptr = APR_BUCKET_NEXT (dptr);
  +                apr_bucket_delete(free_bucket);
  +            } while (dptr != APR_BRIGADE_SENTINEL(*bb));
           }
           else { /* Otherwise pass it along... */
               ap_pass_brigade(f->next, *bb);  /* No SSI tags in this brigade... */
  
  
  

Mime
View raw message