From: Ryan Bloom Date: Thu, 15 Nov 2001 05:05:20 +0000 (+0000) Subject: Fix a file descriptor leak in mod_include. When we include a X-Git-Tag: 2.0.29~125 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c019be7e9b0fe808398eced47945979289f205e2;p=thirdparty%2Fapache%2Fhttpd.git 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. This passes all tests in the test suite. Submitted by: Brian Pane 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 --- diff --git a/CHANGES b/CHANGES index c36f9cfe2fe..7785f1509c3 100644 --- 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 ] + *) 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 diff --git a/modules/filters/mod_include.c b/modules/filters/mod_include.c index 368fb2dbd3d..5f406b79cab 100644 --- a/modules/filters/mod_include.c +++ b/modules/filters/mod_include.c @@ -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) diff --git a/modules/filters/mod_include.h b/modules/filters/mod_include.h index 190b61ba150..82c3bfb0ff6 100644 --- a/modules/filters/mod_include.h +++ b/modules/filters/mod_include.h @@ -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