From 48ae6610b471b3fda58c7818ee301c74b0a3164e Mon Sep 17 00:00:00 2001 From: Cliff Woolley Date: Sat, 21 Apr 2001 22:01:05 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88909 13f79535-47bb-0310-9956-ffa450edef68 --- modules/filters/mod_include.c | 42 ++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/modules/filters/mod_include.c b/modules/filters/mod_include.c index 51ff104462..ff3a1af295 100644 --- a/modules/filters/mod_include.c +++ b/modules/filters/mod_include.c @@ -2387,11 +2387,15 @@ static void send_parsed_content(apr_bucket_brigade **bb, request_rec *r, /* 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 @@ static void send_parsed_content(apr_bucket_brigade **bb, request_rec *r, 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 @@ static void send_parsed_content(apr_bucket_brigade **bb, request_rec *r, 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 @@ static void send_parsed_content(apr_bucket_brigade **bb, request_rec *r, /* 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... */ -- 2.50.1