From d409bcf7e80cdce31c9c92046a0f60b0d9696c89 Mon Sep 17 00:00:00 2001 From: Ian Holsman Date: Sat, 23 Feb 2002 20:56:36 +0000 Subject: [PATCH] make it work with flushes make the false alarm not as generic PR: Obtained from: Submitted by: Reviewed by: Ian, Brian, Justin git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93553 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 2 ++ modules/filters/mod_include.c | 34 ++++++++++++++++++++++++++++++---- modules/filters/mod_include.h | 4 ++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 05f4215bbd..5c52a5f8ec 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,6 @@ Changes with Apache 2.0.33-dev + *) mod-include: make it handle flush'es and fix the 'false-alarm' + [Justin Everkrantz, Brian Pane, Ian Holsman] *) ap_get_*_filter_handle() functions to allow 3rd party modules to lookup filter handles so they can bypass the filter name diff --git a/modules/filters/mod_include.c b/modules/filters/mod_include.c index 2f1cd5eff5..c6880ba9cd 100644 --- a/modules/filters/mod_include.c +++ b/modules/filters/mod_include.c @@ -366,7 +366,14 @@ static apr_bucket *find_start_sequence(apr_bucket *dptr, include_ctx_t *ctx, break; } - if (ctx->bytes_parsed >= BYTE_COUNT_THRESHOLD) { + if (APR_BUCKET_IS_FLUSH(dptr)) { + apr_bucket *old = dptr; + dptr = APR_BUCKET_NEXT(old); + APR_BUCKET_REMOVE(old); + ctx->output_now = 1; + ctx->output_flush = 1; + } + else if (ctx->bytes_parsed >= BYTE_COUNT_THRESHOLD) { ctx->output_now = 1; } else if (ctx->bytes_parsed > 0) { @@ -430,9 +437,11 @@ static apr_bucket *find_start_sequence(apr_bucket *dptr, include_ctx_t *ctx, } /* False alarm... - * send out the unmatched part */ - if (ctx->parse_pos > 0) { + /* send out the unmatched part + */ + + if ((ctx->parse_pos > 0) && (ctx->bytes_parsed == 0)) { apr_bucket *tmp_buck; tmp_buck = apr_bucket_pool_create(apr_pstrndup(ctx->pool, ctx->start_seq, @@ -441,6 +450,8 @@ static apr_bucket *find_start_sequence(apr_bucket *dptr, include_ctx_t *ctx, ctx->pool); APR_BUCKET_INSERT_BEFORE(dptr, tmp_buck); } + + ctx->state = PRE_HEAD; } @@ -501,6 +512,8 @@ static apr_bucket *find_start_sequence(apr_bucket *dptr, include_ctx_t *ctx, } dptr = APR_BUCKET_NEXT(dptr); } while (dptr != APR_BRIGADE_SENTINEL(bb)); + + return NULL; } @@ -519,7 +532,14 @@ static apr_bucket *find_end_sequence(apr_bucket *dptr, include_ctx_t *ctx, if (APR_BUCKET_IS_EOS(dptr)) { break; } - if (ctx->bytes_parsed >= BYTE_COUNT_THRESHOLD) { + if (APR_BUCKET_IS_FLUSH(dptr)) { + apr_bucket *old = dptr; + dptr = APR_BUCKET_NEXT(old); + APR_BUCKET_REMOVE(old); + ctx->output_now = 1; + ctx->output_flush = 1; + } + else if (ctx->bytes_parsed >= BYTE_COUNT_THRESHOLD) { ctx->output_now = 1; } else if (ctx->bytes_parsed > 0) { @@ -2888,12 +2908,17 @@ static apr_status_t send_parsed_content(apr_bucket_brigade **bb, (ctx->bytes_parsed >= BYTE_COUNT_THRESHOLD))) { /* Send the large chunk of pre-tag bytes... */ tag_and_after = apr_brigade_split(*bb, tmp_dptr); + if (ctx->output_flush) { + APR_BRIGADE_INSERT_TAIL(*bb, apr_bucket_flush_create()); + } + rv = ap_pass_brigade(f->next, *bb); if (rv != APR_SUCCESS) { return rv; } *bb = tag_and_after; dptr = tmp_dptr; + ctx->output_flush = 0; ctx->bytes_parsed = 0; ctx->output_now = 0; } @@ -2936,6 +2961,7 @@ static apr_status_t send_parsed_content(apr_bucket_brigade **bb, if (rv != APR_SUCCESS) { return rv; } + ctx->output_flush = 0; ctx->output_now = 0; } } diff --git a/modules/filters/mod_include.h b/modules/filters/mod_include.h index 1f143884b3..d7996fa5d8 100644 --- a/modules/filters/mod_include.h +++ b/modules/filters/mod_include.h @@ -143,6 +143,7 @@ typedef struct include_filter_ctx { int bytes_parsed; apr_status_t status; int output_now; + int output_flush; apr_bucket *head_start_bucket; apr_size_t head_start_index; @@ -206,6 +207,9 @@ if ((APR_BRIGADE_EMPTY(cntxt->ssi_tag_brigade)) && \ apr_bucket_brigade *tag_plus; \ \ tag_plus = apr_brigade_split(brgd, cntxt->head_start_bucket); \ + if (cntxt->output_flush) { \ + APR_BRIGADE_INSERT_TAIL(brgd, apr_bucket_flush_create()); \ + } \ rc = ap_pass_brigade(next, brgd); \ cntxt->bytes_parsed = 0; \ brgd = tag_plus; \ -- 2.50.1