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 Fri, 20 Apr 2001 20:58:29 GMT
jwoolley    01/04/20 13:58:28

  Modified:    modules/filters mod_include.c
  Log:
  Change mod_include to use the latest bucket API tricks.  This gets
  rid of some obscure while loop magic that had to be done before,
  making mod_include easier to read and a better example for future
  filter writers.
  
  There should be no semantic changes in this patch... just a 1-to-1
  mapping from while loops to bucket API calls that do the same thing.
  
  Reviewed by:	Paul J. Reder
  
  Revision  Changes    Path
  1.108     +19 -47    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.107
  retrieving revision 1.108
  diff -u -d -u -r1.107 -r1.108
  --- mod_include.c	2001/04/10 16:57:27	1.107
  +++ mod_include.c	2001/04/20 20:58:28	1.108
  @@ -2378,27 +2378,20 @@
               if ((do_cleanup) && (!APR_BRIGADE_EMPTY(ctx->ssi_tag_brigade)))
{
                   apr_bucket *tmp_bkt;
   
  -                tmp_bkt = apr_bucket_immortal_create(STARTING_SEQUENCE, cleanup_bytes);
  +                tmp_bkt = apr_bucket_immortal_create(STARTING_SEQUENCE,
  +                                                     cleanup_bytes);
                   APR_BRIGADE_INSERT_HEAD(*bb, tmp_bkt);
  -
  -                while (!APR_BRIGADE_EMPTY(ctx->ssi_tag_brigade)) {
  -                    tmp_bkt = APR_BRIGADE_FIRST(ctx->ssi_tag_brigade);
  -                    apr_bucket_delete(tmp_bkt);
  -                }
  +                apr_brigade_cleanup(ctx->ssi_tag_brigade);
               }
   
               /* 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) &&
  -                (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);
  -                }
  +            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);
               }
   
               /* Adjust the current bucket position based on what was found... */
  @@ -2478,20 +2471,13 @@
                   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)) {
  -                    while (!APR_BRIGADE_EMPTY(ctx->ssi_tag_brigade)) {
  -                        tmp_bkt = APR_BRIGADE_FIRST(ctx->ssi_tag_brigade);
  -                        apr_bucket_delete(tmp_bkt);
  -                    }
  +                    apr_brigade_cleanup(ctx->ssi_tag_brigade);
                   }
                   else {
  -                    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)));
  +                    apr_bucket_brigade *temp_bb = *bb;
  +                    *bb = apr_brigade_split(temp_bb, dptr);
  +                    apr_brigade_destroy(temp_bb);
                   }
   
                   return;
  @@ -2549,20 +2535,13 @@
               if (content_head == NULL) {
                   content_head = dptr;
               }
  -            tmp_dptr = ctx->head_start_bucket;
               if (!APR_BRIGADE_EMPTY(ctx->ssi_tag_brigade)) {
  -                while (!APR_BRIGADE_EMPTY(ctx->ssi_tag_brigade)) {
  -                    tmp_bkt = APR_BRIGADE_FIRST(ctx->ssi_tag_brigade);
  -                    apr_bucket_delete(tmp_bkt);
  -                }
  +                apr_brigade_cleanup(ctx->ssi_tag_brigade);
               }
               else {
  -                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)));
  +                apr_bucket_brigade *temp_bb = *bb;
  +                *bb = apr_brigade_split(temp_bb, content_head);
  +                apr_brigade_destroy(temp_bb);
               }
               if (ctx->combined_tag == tmp_buf) {
                   memset (ctx->combined_tag, '\0', ctx->tag_length);
  @@ -2582,10 +2561,7 @@
               ctx->directive_length  = 0;
   
               if (!APR_BRIGADE_EMPTY(ctx->ssi_tag_brigade)) {
  -                while (!APR_BRIGADE_EMPTY(ctx->ssi_tag_brigade)) {
  -                    tmp_bkt = APR_BRIGADE_FIRST(ctx->ssi_tag_brigade);
  -                    apr_bucket_delete(tmp_bkt);
  -                }
  +                apr_brigade_cleanup(ctx->ssi_tag_brigade);
               }
   
               ctx->state     = PRE_HEAD;
  @@ -2602,12 +2578,8 @@
           /* Inside a false conditional (if, elif, else), so toss it all... */
           if ((dptr != APR_BRIGADE_SENTINEL(*bb)) &&
               (!(ctx->flags & FLAG_PRINTING))) {
  -            apr_bucket *free_bucket;
  -            do {
  -                free_bucket = dptr;
  -                dptr = APR_BUCKET_NEXT (dptr);
  -                apr_bucket_delete(free_bucket);
  -            } while (dptr != APR_BRIGADE_SENTINEL(*bb));
  +            apr_brigade_cleanup(*bb);
  +            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