Commit 98d8e8d3 authored by Ryan Bloom's avatar Ryan Bloom
Browse files

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
parent 0f75d87c
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
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
+21 −4
Original line number Diff line number Diff line
@@ -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);
            }
            return APR_SUCCESS;
        }