]> granicus.if.org Git - apache/commitdiff
Create Files, and thus MMAPs, out of the request pool, not the
authorRyan Bloom <rbb@apache.org>
Sun, 29 Apr 2001 17:05:49 +0000 (17:05 +0000)
committerRyan Bloom <rbb@apache.org>
Sun, 29 Apr 2001 17:05:49 +0000 (17:05 +0000)
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

CHANGES
server/core.c

diff --git a/CHANGES b/CHANGES
index c016f48cb51326490e001b793abb084470bd1ee3..9258562dbcf8b8553d0c09e4b0df23899f0ebcd8 100644 (file)
--- 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
index 355b55ed7cf7cfd187396ca1711ec043141e8d97..b371b2db24917ed95590ac263ddec65400b3f5a9 100644 (file)
@@ -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;
         }