]> granicus.if.org Git - apache/commitdiff
Fix a file descriptor leak in mod_include. When we include a
authorRyan Bloom <rbb@apache.org>
Thu, 15 Nov 2001 05:05:20 +0000 (05:05 +0000)
committerRyan Bloom <rbb@apache.org>
Thu, 15 Nov 2001 05:05:20 +0000 (05:05 +0000)
file, we use a sub-request, but we didn't destroy the sub-request
immediately, instead we waited until the original request was
done.  This patch closes the sub-request as soon as the data is
done being generated.

This passes all tests in the test suite.

Submitted by: Brian Pane <bpane@pacbell.net>
Reviewed by: Ryan Bloom and Cliff Woolley

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91963 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/filters/mod_include.c
modules/filters/mod_include.h

diff --git a/CHANGES b/CHANGES
index c36f9cfe2feeb55d261cbea0f25600df2102521b..7785f1509c3a67bf9d34765be6c333273b4a79e2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,11 @@
 Changes with Apache 2.0.29-dev
 
+  *) Fix a file descriptor leak in mod_include.  When we include a
+     file, we use a sub-request, but we didn't destroy the sub-request
+     immediately, instead we waited until the original request was
+     done.  This patch closes the sub-request as soon as the data is
+     done being generated.  [Brian Pane <bpane@pacbell.net>]
+
   *) Allow modules that add sockets to the ap_listeners list to
      define the function that should be used to accept on that
      socket.  Each MPM can define their own function to use for
index 368fb2dbd3d31dc0a42e2a96e43504ef4abb918e..5f406b79cab2832ddd91ad5e605a37d894d2188e 100644 (file)
@@ -1126,11 +1126,8 @@ static int handle_include(include_ctx_t *ctx, apr_bucket_brigade **bb,
                                         *inserted_head);
                 }
 
-                /* destroy the sub request if it's not a nested include 
-                 * (crumb) */
-                if (rr != NULL
-                    && ap_get_module_config(rr->request_config, 
-                       &include_module) != NESTED_INCLUDE_MAGIC) {
+                /* destroy the sub request */
+                if (rr != NULL) {
                     ap_destroy_sub_req(rr);
                 }
             }
@@ -3024,7 +3021,6 @@ static apr_status_t includes_filter(ap_filter_t *f, apr_bucket_brigade *b)
     request_rec *r = f->r;
     include_ctx_t *ctx = f->ctx;
     request_rec *parent;
-    apr_status_t rv;
     include_dir_config *conf = 
                    (include_dir_config *)ap_get_module_config(r->per_dir_config,
                                                               &include_module);
@@ -3108,15 +3104,7 @@ static apr_status_t includes_filter(ap_filter_t *f, apr_bucket_brigade *b)
     apr_table_unset(f->r->headers_out, "ETag");
     apr_table_unset(f->r->headers_out, "Last-Modified");
 
-    rv = send_parsed_content(&b, r, f);
-
-    if (parent) {
-        /* signify that the sub request should not be killed */
-        ap_set_module_config(r->request_config, &include_module,
-            NESTED_INCLUDE_MAGIC);
-    }
-
-    return rv;
+    return send_parsed_content(&b, r, f);
 }
 
 static void ap_register_include_handler(char *tag, include_handler_fn_t *func)
index 190b61ba1505ba7c58edb0dfccea9d86dec1ccf4..82c3bfb0ff62d21660ab13c246f4b24547048298 100644 (file)
@@ -75,9 +75,6 @@
 #define RAW_ASCII_CHAR(ch)  (ch)
 #endif /*APR_CHARSET_EBCDIC*/
 
-/* just need some arbitrary non-NULL pointer which can't also be a request_rec */
-#define NESTED_INCLUDE_MAGIC   (&include_module)
-
 /****************************************************************************
  * Used to keep context information during parsing of a request for SSI tags.
  * This is especially useful if the tag stretches across multiple buckets or