From a1d3d62fc6f608d452ec8398c6ed1e0940c5832a Mon Sep 17 00:00:00 2001 From: Greg Stein Date: Wed, 30 Aug 2000 01:09:09 +0000 Subject: [PATCH] reversing the latest commit; it was vetoed a while back. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86162 13f79535-47bb-0310-9956-ffa450edef68 --- include/util_filter.h | 16 +++++----------- modules/http/http_core.c | 4 ++-- modules/http/http_protocol.c | 2 +- server/util_filter.c | 17 ++++++++++------- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/include/util_filter.h b/include/util_filter.h index a5d100f112..2ce9eeac19 100644 --- a/include/util_filter.h +++ b/include/util_filter.h @@ -255,24 +255,18 @@ API_EXPORT(void) ap_register_filter(const char *name, * from another request, then this filter will be added before those other * filters. * - * To re-iterate that last comment. This function is building a LIFO + * To re-iterate that last comment. This function is building a FIFO * list of filters. Take note of that when adding your filter to the chain. */ /** - * Add a filter to the current request. Filters are added in a LIFO manner. - * The first filter added will be the last filter called. + * Add a filter to the current request. Filters are added in a FIFO manner. + * The first filter added will be the first filter called. * @param name The name of the filter to add * @param ctx Any filter specific data to associate with the filter * @param r The request to add this filter for. - * @param curr The filter to add this filter after. This is incredibly useful - * if you are adding a filter while executing another filter. The - * new filter should be added immediately after the current filter. - * By passing the current filter into ap_add_filter, this is - * accomplished easily. - * @deffunc void ap_add_filter(const char *name, void *ctx, request_rec *r, ap_filter_t *curr) + * @deffunc void ap_add_filter(const char *name, void *ctx, request_rec *r) */ -API_EXPORT(void) ap_add_filter(const char *name, void *ctx, request_rec *r, - ap_filter_t *curr); +API_EXPORT(void) ap_add_filter(const char *name, void *ctx, request_rec *r); /* The next two filters are for abstraction purposes only. They could be * done away with, but that would require that we break modules if we ever diff --git a/modules/http/http_core.c b/modules/http/http_core.c index 72b5dffca9..041f5f8633 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -3089,7 +3089,7 @@ static unsigned short core_port(const request_rec *r) static void core_register_filter(request_rec *r) { - ap_add_filter("CORE", NULL, r, NULL); + ap_add_filter("CORE", NULL, r); } static void register_hooks(void) @@ -3109,7 +3109,7 @@ static void register_hooks(void) * request-processing time. */ ap_hook_insert_filter(core_register_filter, NULL, NULL, AP_HOOK_MIDDLE); - ap_register_filter("CORE", core_filter, AP_FTYPE_CONNECTION); + ap_register_filter("CORE", core_filter, AP_FTYPE_CONNECTION + 1); ap_register_filter("CHUNK", chunk_filter, AP_FTYPE_CONNECTION); } diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 4d69912470..d74516814c 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -1862,7 +1862,7 @@ API_EXPORT(void) ap_send_http_header(request_rec *r) if (r->chunked) { apr_table_mergen(r->headers_out, "Transfer-Encoding", "chunked"); apr_table_unset(r->headers_out, "Content-Length"); - ap_add_filter("CHUNK", NULL, r, NULL); + ap_add_filter("CHUNK", NULL, r); } if (r->byterange > 1) diff --git a/server/util_filter.c b/server/util_filter.c index 29abc84018..491a52b379 100644 --- a/server/util_filter.c +++ b/server/util_filter.c @@ -117,8 +117,7 @@ API_EXPORT(void) ap_register_filter(const char *name, apr_register_cleanup(FILTER_POOL, NULL, filter_cleanup, apr_null_cleanup); } -API_EXPORT(void) ap_add_filter(const char *name, void *ctx, request_rec *r, - ap_filter_t *curr) +API_EXPORT(void) ap_add_filter(const char *name, void *ctx, request_rec *r) { ap_filter_rec_t *frec = registered_filters; @@ -131,14 +130,18 @@ API_EXPORT(void) ap_add_filter(const char *name, void *ctx, request_rec *r, f->ftype = frec->ftype; f->r = r; - if (curr) { - f->next = curr->next; - curr->next = f; - } - else { + if (INSERT_BEFORE(f, r->filters)) { f->next = r->filters; r->filters = f; } + else { + ap_filter_t *fscan = r->filters; + while (!INSERT_BEFORE(f, fscan->next)) + fscan = fscan->next; + f->next = fscan->next; + fscan->next = f; + } + break; } } -- 2.50.1