From: Paul Querna Date: Wed, 21 Jul 2010 18:11:07 +0000 (+0000) Subject: Run filter "init" functions exactly once per request. No longer run X-Git-Tag: 2.2.16~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebf3ba3204ae05735e2f3924e772407a21f73642;p=thirdparty%2Fapache%2Fhttpd.git Run filter "init" functions exactly once per request. No longer run init functions for connection filters (doing an "init" once per handler invocation makes no sense for a connection filter). No longer run init functions multiple times per request if a subrequest is used. * include/util_filter.h (ap_filter_rec_t): Clarify use of the init function pointer. * server/config.c (invoke_filter_init): Drop ap_ prefix for private function; take a request_rec pointer and only invoke filters with matching request. (ap_invoke_handler): Adjust accordingly. PR: 49328 Reviewed by: rpluem git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@966340 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 3d7aa1b67fe..52d160c472c 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,10 @@ Changes with Apache 2.2.16 mod_proxy_ajp, mod_proxy_http, mod_reqtimeout: Fix timeout detection for platforms Windows, Netware and OS2. PR: 49417. [Rainer Jung] + *) core: Filter init functions are now run strictly once per request + before handler invocation. The init functions are no longer run + for connection filters. PR 49328. [Joe Orton] + *) mod_filter: enable it to act on non-200 responses. PR 48377 [Nick Kew] diff --git a/STATUS b/STATUS index ef1cfa684d2..28e12b0b6fd 100644 --- a/STATUS +++ b/STATUS @@ -86,14 +86,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * core: Filter init functions are now run strictly once per request - before handler invocation. The init functions are no longer run - for connection filters. PR 49328. - Trunk version of patch: - http://svn.apache.org/viewcvs.cgi?rev=953311&view=rev - Backport version for 2.2.x of patch: - Trunk version of patch works - +1: rpluem, jim, pquerna PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/include/util_filter.h b/include/util_filter.h index d0846d9fada..dbcb43701b2 100644 --- a/include/util_filter.h +++ b/include/util_filter.h @@ -221,10 +221,13 @@ struct ap_filter_rec_t { /** The function to call when this filter is invoked. */ ap_filter_func filter_func; - /** The function to call before the handlers are invoked. Notice - * that this function is called only for filters participating in - * the http protocol. Filters for other protocols are to be - * initialized by the protocols themselves. + /** The function to call directly before the handlers are invoked + * for a request. The init function is called once directly + * before running the handlers for a request or subrequest. The + * init function is never called for a connection filter (with + * ftype >= AP_FTYPE_CONNECTION). Any use of this function for + * filters for protocols other than HTTP is specified by the + * module supported that protocol. */ ap_init_filter_func filter_init_func; diff --git a/server/config.c b/server/config.c index 101d0e4ed06..7e5e06b269e 100644 --- a/server/config.c +++ b/server/config.c @@ -306,10 +306,14 @@ AP_CORE_DECLARE(ap_conf_vector_t *) ap_create_per_dir_config(apr_pool_t *p) return create_empty_config(p); } -static int ap_invoke_filter_init(ap_filter_t *filters) +/* Invoke the filter_init_func for all filters with FILTERS where f->r + * matches R. Restricting to a matching R avoids re-running init + * functions for filters configured for r->main where r is a + * subrequest. */ +static int invoke_filter_init(request_rec *r, ap_filter_t *filters) { while (filters) { - if (filters->frec->filter_init_func) { + if (filters->frec->filter_init_func && filters->r == r) { int result = filters->frec->filter_init_func(filters); if (result != OK) { return result; @@ -342,11 +346,11 @@ AP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r) * run their init function to let them do any magic before we could * start generating data. */ - result = ap_invoke_filter_init(r->input_filters); + result = invoke_filter_init(r, r->input_filters); if (result != OK) { return result; } - result = ap_invoke_filter_init(r->output_filters); + result = invoke_filter_init(r, r->output_filters); if (result != OK) { return result; }