From: Greg Ames Date: Fri, 8 Nov 2002 17:19:10 +0000 (+0000) Subject: use a subpool of c->pool for resources which are set aside, then clear it X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b1a6647fb190eec6e20d6c6fca61a2f8c249b13;p=thirdparty%2Fapache%2Fhttpd.git use a subpool of c->pool for resources which are set aside, then clear it after writing the data to the network. This closes files sooner with keepalive connections. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@97462 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 6b43a82a6da..729a0d105aa 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,10 @@ Changes with Apache 2.0.44 + *) Fix a bug where we keep files open until the end of a + keepalive connection, which can result in: + (24)Too many open files: file permissions deny server access + especially on threaded servers. [Greg Ames, Jeff Trawick] + *) Fix a bug in which mod_proxy sent an invalid Content-Length when a proxied URL was invoked as a server-side include within a page generated in response to a form POST. [Brian Pane] diff --git a/include/httpd.h b/include/httpd.h index b86dab0b4be..3e026243bf2 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -1115,10 +1115,9 @@ struct server_rec { typedef struct core_output_filter_ctx { apr_bucket_brigade *b; - apr_pool_t *subpool; /* subpool of c->pool used for data saved after a - * request is finished - */ - int subpool_has_stuff; /* anything in the subpool? */ + apr_pool_t *deferred_write_pool; /* subpool of c->pool used for resources + * which may outlive the request + */ } core_output_filter_ctx_t; typedef struct core_filter_ctx { diff --git a/server/core.c b/server/core.c index f11923059dd..fb3010706a7 100644 --- a/server/core.c +++ b/server/core.c @@ -3923,7 +3923,10 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b) } } } - ap_save_brigade(f, &ctx->b, &b, c->pool); + if (!ctx->deferred_write_pool) { + apr_pool_create(&ctx->deferred_write_pool, c->pool); + } + ap_save_brigade(f, &ctx->b, &b, ctx->deferred_write_pool); return APR_SUCCESS; } @@ -3994,6 +3997,14 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b) } apr_brigade_destroy(b); + + /* drive cleanups for resources which were set aside + * this may occur before or after termination of the request which + * created the resource + */ + if (ctx->deferred_write_pool) { + apr_pool_clear(ctx->deferred_write_pool); + } if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_INFO, rv, c->base_server, "core_output_filter: writing data to the network");