httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davi Arnaut <d...@haxent.com.br>
Subject [PATCH] No temporary file left behind
Date Sun, 28 May 2006 01:52:23 GMT
Hi,

Remove mod_disk_cache temporary files when rename() fails, otherwise
they may accumulate in excess. 

--
Davi Arnaut

Index: modules/cache/mod_disk_cache.c
===================================================================
--- modules/cache/mod_disk_cache.c	(revision 409900)
+++ modules/cache/mod_disk_cache.c	(working copy)
@@ -165,7 +165,10 @@
          */
         rv = apr_file_rename(dobj->tempfile, dobj->datafile, r->pool);
         if (rv != APR_SUCCESS) {
-            /* XXX log */
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, r->server,
+                         "disk_cache: rename tempfile to datafile failed: %s -> %s",
+                         dobj->tempfile, dobj->datafile);
+            apr_file_remove(dobj->tempfile, r->pool);
         }
 
         dobj->tfd = NULL;
@@ -854,6 +857,7 @@
                 ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, r->server,
                     "disk_cache: rename tempfile to varyfile failed: %s -> %s",
                     dobj->tempfile, dobj->hdrsfile);
+                apr_file_remove(dobj->tempfile, r->pool);
                 return rv;
             }
 
@@ -946,6 +950,7 @@
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
                      "disk_cache: rename tempfile to hdrsfile failed: %s -> %s",
                      dobj->tempfile, dobj->hdrsfile);
+        apr_file_remove(dobj->tempfile, r->pool);
         return rv;
     }
 

Mime
View raw message