]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Run filter "init" functions exactly once per request. No longer run
authorPaul Querna <pquerna@apache.org>
Wed, 21 Jul 2010 18:11:07 +0000 (18:11 +0000)
committerPaul Querna <pquerna@apache.org>
Wed, 21 Jul 2010 18:11:07 +0000 (18:11 +0000)
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

CHANGES
STATUS
include/util_filter.h
server/config.c

diff --git a/CHANGES b/CHANGES
index 3d7aa1b67fee2e1a8ec8a957fb6edf508bffa071..52d160c472c2d409ebf08cf7bb7400d92586ac90 100644 (file)
--- 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 ef1cfa684d22d53a3e0eb1660c7cb1de6922b11c..28e12b0b6fd9d4f1557d01d06e7dfc144c9e3c2f 100644 (file)
--- 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 ]
index d0846d9fada5f9f22d70b056f85a10bd996fed30..dbcb43701b21586c5d0edaaf9a5c8e53a9a0e56a 100644 (file)
@@ -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;
 
index 101d0e4ed0678f7d11a49c9614c534699a1138db..7e5e06b269efecd0e0cd5ef404e723009c568e05 100644 (file)
@@ -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;
     }