summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Bloom <rbb@apache.org>2001-04-29 17:05:49 +0000
committerRyan Bloom <rbb@apache.org>2001-04-29 17:05:49 +0000
commitfa2595bb24ac035cf7b13cd03bbfbbcf995a1e7d (patch)
treeabdfadee24f9f03accd4239fd58952a22f73de50
parentbaa865bddf8a38134c67f111b5939f94bdb8665a (diff)
downloadhttpd-fa2595bb24ac035cf7b13cd03bbfbbcf995a1e7d.tar.gz
Create Files, and thus MMAPs, out of the request pool, not the
connection pool. This solves a small resource leak that had us not closing files until a connection was closed. In order to do this, at the end of the core_output_filter, we loop through the brigade and convert any data we have into a single HEAP bucket that we know will survive clearing the request_rec. Submitted by: Ryan Bloom, Justin Erenkrantz <jerenkrantz@ebuilt.com>, Cliff Woolley git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88964 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--CHANGES9
-rw-r--r--server/core.c25
2 files changed, 30 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index c016f48cb5..9258562dbc 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,14 @@
Changes with Apache 2.0.18-dev
+ *) Create Files, and thus MMAPs, out of the request pool, not the
+ connection pool. This solves a small resource leak that had us
+ not closing files until a connection was closed. In order to do
+ this, at the end of the core_output_filter, we loop through the
+ brigade and convert any data we have into a single HEAP bucket
+ that we know will survive clearing the request_rec.
+ [Ryan Bloom, Justin Erenkrantz <jerenkrantz@ebuilt.com>,
+ Cliff Woolley]
+
*) Completely revamp configure so that it preserves the standard make
variables CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS and LIBS by moving
the configure additions to EXTRA_* variables. Also, allow the user
diff --git a/server/core.c b/server/core.c
index 355b55ed7c..b371b2db24 100644
--- a/server/core.c
+++ b/server/core.c
@@ -2965,7 +2965,7 @@ static int default_handler(request_rec *r)
return HTTP_METHOD_NOT_ALLOWED;
}
- if ((status = apr_file_open(&fd, r->filename, APR_READ | APR_BINARY, 0, r->connection->pool)) != APR_SUCCESS) {
+ if ((status = apr_file_open(&fd, r->filename, APR_READ | APR_BINARY, 0, r->pool)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
"file permissions deny server access: %s", r->filename);
return HTTP_FORBIDDEN;
@@ -3134,15 +3134,32 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b)
if ((!fd && !more &&
(nbytes < AP_MIN_BYTES_TO_WRITE) && !APR_BUCKET_IS_FLUSH(e))
|| (APR_BUCKET_IS_EOS(e) && c->keepalive)) {
-
/* NEVER save an EOS in here. If we are saving a brigade with
* an EOS bucket, then we are doing keepalive connections, and
* we want to process to second request fully.
*/
if (APR_BUCKET_IS_EOS(e)) {
- apr_bucket_delete(e);
+ apr_bucket *bucket = NULL;
+ /* If we are in here, then this request is a keepalive. We
+ * need to be certain that any data in a bucket is valid
+ * after the request_pool is cleared.
+ */
+ if (ctx->b == NULL) {
+ ctx->b = apr_brigade_create(f->c->pool);
+ }
+
+ APR_BRIGADE_FOREACH(bucket, b) {
+ const char *str;
+ apr_size_t n;
+
+ rv = apr_bucket_read(bucket, &str, &n, APR_BLOCK_READ);
+ apr_brigade_write(ctx->b, NULL, NULL, str, n);
+ }
+ apr_brigade_destroy(b);
+ }
+ else {
+ ap_save_brigade(f, &ctx->b, &b);
}
- ap_save_brigade(f, &ctx->b, &b);
return APR_SUCCESS;
}