]> granicus.if.org Git - apache/commitdiff
Implement mod_disk_cache's remove_url.
authorJustin Erenkrantz <jerenkrantz@apache.org>
Thu, 11 Aug 2005 17:31:10 +0000 (17:31 +0000)
committerJustin Erenkrantz <jerenkrantz@apache.org>
Thu, 11 Aug 2005 17:31:10 +0000 (17:31 +0000)
(Minor tweaks and comment fixes by Justin.)

Suggested by: Paul Querna, Justin Erenkrantz
Submitted by: Rudiger Plum <ruediger.pluem vodafone.com>
Reviewed by: Justin Erenkrantz

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@231486 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/cache/mod_disk_cache.c

diff --git a/CHANGES b/CHANGES
index 09ccc9b022d550f521394c5b046b3ae0206ecff7..d1d5510d4f070c2edc19bc51e08111df84a3ddfb 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.3.0
 
+  *) mod_disk_cache: Properly remove files from cache when needed.
+     [Rüdiger Plüm ruediger.pluem vodafone.com]
+
   *) mod_disk_cache: Support htcacheclean removing directories.
      [Andreas Steinmetz]
 
index 57e61c622775cdbff70bccb8d8ff116b60fb7198..47d5eb94eb5a277a009d2b1c3b305a4a38188867 100644 (file)
@@ -541,9 +541,51 @@ static int remove_entity(cache_handle_t *h)
     return OK;
 }
 
-static int remove_url(const char *key)
+static int remove_url(cache_handle_t *h, apr_pool_t *p)
 {
-    /* XXX: Delete file from cache! */
+    apr_status_t rc;
+    disk_cache_object_t *dobj;
+
+    /* Get disk cache object from cache handle */
+    dobj = (disk_cache_object_t *) h->cache_obj->vobj;
+    if (!dobj) {
+        return DECLINED;
+    }
+
+    /* Delete headers file */
+    if (dobj->hdrsfile) {
+        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,
+                     "disk_cache: Deleting %s from cache.", dobj->hdrsfile);
+
+        rc = apr_file_remove(dobj->hdrsfile, p);
+        if ((rc != APR_SUCCESS) && (rc != APR_ENOENT)) {
+            /* Will only result in an output if httpd is started with -e debug.
+             * For reason see log_error_core for the case s == NULL.
+             */
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, rc, NULL,
+                   "disk_cache: Failed to delete headers file %s from cache.",
+                         dobj->hdrsfile);
+            return DECLINED;
+        }
+    }
+
+     /* Delete data file */
+    if (dobj->datafile) {
+        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,
+                     "disk_cache: Deleting %s from cache.", dobj->datafile);
+
+        rc = apr_file_remove(dobj->datafile, p);
+        if ((rc != APR_SUCCESS) && (rc != APR_ENOENT)) {
+            /* Will only result in an output if httpd is started with -e debug.
+             * For reason see log_error_core for the case s == NULL.
+             */
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, rc, NULL,
+                      "disk_cache: Failed to delete data file %s from cache.",
+                         dobj->datafile);
+            return DECLINED;
+        }
+    }
+
     return OK;
 }