You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mi...@apache.org on 2011/11/21 18:09:44 UTC
svn commit: r1204602 - in /httpd/httpd/branches/2.4.x: CHANGES
modules/cache/mod_cache_disk.c
Author: minfrin
Date: Mon Nov 21 17:09:44 2011
New Revision: 1204602
URL: http://svn.apache.org/viewvc?rev=1204602&view=rev
Log:
Backport:
mod_cache_disk: Make sure we check return codes on all writes and attempts
to close, and clean up after ourselves in these cases. PR43589.
Modified:
httpd/httpd/branches/2.4.x/CHANGES
httpd/httpd/branches/2.4.x/modules/cache/mod_cache_disk.c
Modified: httpd/httpd/branches/2.4.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/CHANGES?rev=1204602&r1=1204601&r2=1204602&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.4.x/CHANGES [utf-8] Mon Nov 21 17:09:44 2011
@@ -1,6 +1,10 @@
-*- coding: utf-8 -*-
Changes with Apache 2.4.0
+ *) mod_cache_disk: Make sure we check return codes on all writes and
+ attempts to close, and clean up after ourselves in these cases.
+ PR43589. [Graham Leggett]
+
*) mod_cache_disk: Remove the unnecessary intermediate brigade while
writing to disk. Fixes a problem where mod_disk_cache was leaving
buckets in the intermediate brigade and not passing them to out on
Modified: httpd/httpd/branches/2.4.x/modules/cache/mod_cache_disk.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/cache/mod_cache_disk.c?rev=1204602&r1=1204601&r2=1204602&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/cache/mod_cache_disk.c (original)
+++ httpd/httpd/branches/2.4.x/modules/cache/mod_cache_disk.c Mon Nov 21 17:09:44 2011
@@ -969,23 +969,47 @@ static apr_status_t write_headers(cache_
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r,
- "cache_disk: could not create temp file %s",
+ "cache_disk: could not create vary file %s",
dobj->vary.tempfile);
return rv;
}
amt = sizeof(format);
- apr_file_write(dobj->vary.tempfd, &format, &amt);
+ rv = apr_file_write(dobj->vary.tempfd, &format, &amt);
+ if (rv != APR_SUCCESS) {
+ ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r,
+ "cache_disk: could not write to vary file %s",
+ dobj->vary.tempfile);
+ apr_file_close(dobj->vary.tempfd);
+ apr_pool_destroy(dobj->vary.pool);
+ return rv;
+ }
amt = sizeof(h->cache_obj->info.expire);
- apr_file_write(dobj->vary.tempfd, &h->cache_obj->info.expire, &amt);
+ rv = apr_file_write(dobj->vary.tempfd, &h->cache_obj->info.expire,
+ &amt);
+ if (rv != APR_SUCCESS) {
+ ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r,
+ "cache_disk: could not write to vary file %s",
+ dobj->vary.tempfile);
+ apr_file_close(dobj->vary.tempfd);
+ apr_pool_destroy(dobj->vary.pool);
+ return rv;
+ }
varray = apr_array_make(r->pool, 6, sizeof(char*));
tokens_to_array(r->pool, tmp, varray);
store_array(dobj->vary.tempfd, varray);
- apr_file_close(dobj->vary.tempfd);
+ rv = apr_file_close(dobj->vary.tempfd);
+ if (rv != APR_SUCCESS) {
+ ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r,
+ "cache_disk: could not close vary file %s",
+ dobj->vary.tempfile);
+ apr_pool_destroy(dobj->vary.pool);
+ return rv;
+ }
tmp = regen_key(r->pool, dobj->headers_in, varray, dobj->name);
dobj->prefix = dobj->hdrs.file;
@@ -1002,7 +1026,7 @@ static apr_status_t write_headers(cache_
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r,
- "cache_disk: could not create temp file %s",
+ "cache_disk: could not create header file %s",
dobj->hdrs.tempfile);
return rv;
}
@@ -1034,6 +1058,7 @@ static apr_status_t write_headers(cache_
"cache_disk: could not write info to header file %s",
dobj->hdrs.tempfile);
apr_file_close(dobj->hdrs.tempfd);
+ apr_pool_destroy(dobj->hdrs.pool);
return rv;
}
@@ -1044,6 +1069,7 @@ static apr_status_t write_headers(cache_
"cache_disk: could not write out-headers to header file %s",
dobj->hdrs.tempfile);
apr_file_close(dobj->hdrs.tempfd);
+ apr_pool_destroy(dobj->hdrs.pool);
return rv;
}
}
@@ -1057,11 +1083,19 @@ static apr_status_t write_headers(cache_
"cache_disk: could not write in-headers to header file %s",
dobj->hdrs.tempfile);
apr_file_close(dobj->hdrs.tempfd);
+ apr_pool_destroy(dobj->hdrs.pool);
return rv;
}
}
- apr_file_close(dobj->hdrs.tempfd); /* flush and close */
+ rv = apr_file_close(dobj->hdrs.tempfd); /* flush and close */
+ if (rv != APR_SUCCESS) {
+ ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r,
+ "cache_disk: could not close header file %s",
+ dobj->hdrs.tempfile);
+ apr_pool_destroy(dobj->hdrs.pool);
+ return rv;
+ }
return APR_SUCCESS;
}
@@ -1209,7 +1243,12 @@ static apr_status_t store_body(cache_han
const char *cl_header = apr_table_get(r->headers_out, "Content-Length");
if (dobj->data.tempfd) {
- apr_file_close(dobj->data.tempfd);
+ rv = apr_file_close(dobj->data.tempfd);
+ if (rv != APR_SUCCESS) {
+ /* Buffered write failed, abandon attempt to write */
+ apr_pool_destroy(dobj->data.pool);
+ return rv;
+ }
}
if (r->connection->aborted || r->no_cache) {