You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rp...@apache.org on 2006/05/28 12:32:04 UTC

svn commit: r409942 - in /httpd/httpd/trunk: CHANGES modules/cache/mod_disk_cache.c

Author: rpluem
Date: Sun May 28 03:32:01 2006
New Revision: 409942

URL: http://svn.apache.org/viewvc?rev=409942&view=rev
Log:
* Remove temporary files if renaming fails, otherwise they may accumulate.

Submitted by: Davi Arnaut <davi haxent.com.br>
Reviewed by: rpluem

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/cache/mod_disk_cache.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=409942&r1=409941&r2=409942&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sun May 28 03:32:01 2006
@@ -2,6 +2,9 @@
 Changes with Apache 2.3.0
   [Remove entries to the current 2.0 and 2.2 section below, when backported]
 
+  *) mod_disk_cache: Delete temporary files if they cannot be renamed to their
+     final name. [Davi Arnaut <davi haxent.com.br>]
+
   *) Worker MPM: On graceless shutdown or restart, send signals to
      each worker thread to wake them up if they're polling on a
      Keep-Alive connection.  PR 38737.  [Chris Darroch]

Modified: httpd/httpd/trunk/modules/cache/mod_disk_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_disk_cache.c?rev=409942&r1=409941&r2=409942&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_disk_cache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_disk_cache.c Sun May 28 03:32:01 2006
@@ -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;
     }
 



Re: svn commit: r409942 - in /httpd/httpd/trunk: CHANGES modules/cache/mod_disk_cache.c

Posted by Ruediger Pluem <rp...@apache.org>.

On 05/28/2006 02:33 PM, Colm MacCarthaigh wrote:
> On Sun, May 28, 2006 at 10:32:04AM -0000, rpluem@apache.org wrote:

> 
> A significant source of this kind of error is that the filesystem
> suddenly becomes read-only. Either to a protective automative re-mount
> by the kernel, a log journal becoming full, in which case the remove
> will also fail :/

Thats true, but

1. In this case no further temporary files get created anyway.
2. Trying to remove it does not really hurt, even if it fails.

OTH if becoming read-only is not the source of the error we clean things up.


Regards

Rüdiger

Re: svn commit: r409942 - in /httpd/httpd/trunk: CHANGES modules/cache/mod_disk_cache.c

Posted by Colm MacCarthaigh <co...@stdlib.net>.
On Sun, May 28, 2006 at 10:32:04AM -0000, rpluem@apache.org wrote:
>          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);
>          }

A significant source of this kind of error is that the filesystem
suddenly becomes read-only. Either to a protective automative re-mount
by the kernel, a log journal becoming full, in which case the remove
will also fail :/

-- 
Colm MacCárthaigh                        Public Key: colm+pgp@stdlib.net