Commit 32c1e8d5 authored by Ryan Bloom's avatar Ryan Bloom
Browse files

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 <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
parent 3551f5ed
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
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
+3 −15
Original line number Diff line number Diff line
@@ -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)
+0 −3
Original line number Diff line number Diff line
@@ -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