diff options
author | Bill Stoddard <stoddard@apache.org> | 2001-05-11 19:34:17 +0200 |
---|---|---|
committer | Bill Stoddard <stoddard@apache.org> | 2001-05-11 19:34:17 +0200 |
commit | c13afe3fd50058fb38dce6d4901044702f86f9e0 (patch) | |
tree | 611515287ca4603b88aeab5a4ae60a579c31bcb7 | |
parent | Allows Mod_proxy to be dynamically loaded on win32 systems (diff) | |
download | apache2-c13afe3fd50058fb38dce6d4901044702f86f9e0.tar.xz apache2-c13afe3fd50058fb38dce6d4901044702f86f9e0.zip |
Do not send apr_file_t allocated out of the pconf pool down the
filter chain. This is not perfect but better. Need to do some
more work in apr_os_file_put to initialize fields a bit better.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89086 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | modules/cache/mod_file_cache.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/modules/cache/mod_file_cache.c b/modules/cache/mod_file_cache.c index 345a8e108b..39f8b17ad0 100644 --- a/modules/cache/mod_file_cache.c +++ b/modules/cache/mod_file_cache.c @@ -328,6 +328,8 @@ static int sendfile_handler(request_rec *r, a_file *file) #if APR_HAS_SENDFILE apr_size_t nbytes; apr_status_t rv = APR_EINIT; + apr_file_t *rfile; + apr_os_file_t fd; /* A cached file handle (more importantly, its file pointer) is * shared by all threads in the process. The file pointer will @@ -350,8 +352,14 @@ static int sendfile_handler(request_rec *r, a_file *file) return DECLINED; } - - rv = ap_send_fd(file->file, r, 0, file->finfo.size, &nbytes); + /* Create an apr_file_t anchored out of the request pool to use + * on the call to ap_send_fd(). The cached apr_file_t is allocated + * out of pconf (a life of the server pool) and sending it down + * the filter chain could cause memory leaks. + */ + apr_os_file_get(&fd, file->file); + apr_os_file_put(&rfile, &fd, r->pool); + rv = ap_send_fd(rfile, r, 0, file->finfo.size, &nbytes); if (rv != APR_SUCCESS) { /* ap_send_fd will log the error */ return HTTP_INTERNAL_SERVER_ERROR; |