]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Improves the user friendliness of the CacheRoot processing
authorPaul J. Reder <rederpj@apache.org>
Fri, 8 Nov 2002 22:42:19 +0000 (22:42 +0000)
committerPaul J. Reder <rederpj@apache.org>
Fri, 8 Nov 2002 22:42:19 +0000 (22:42 +0000)
over my last pass. This version avoids the pool allocations
but doesn't avoid all of the runtime checks. It no longer
terminates during post-config processing. An error is logged
once per worker, indicating that the CacheRoot needs to be set.
[Paul J. Reder]

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

CHANGES
STATUS
modules/experimental/mod_disk_cache.c

diff --git a/CHANGES b/CHANGES
index 729a0d105aab057732c595fed2326dba0b5b9b68..9b3c5fb71d79e4209fddad0e70b20f3aa31fb3b7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,12 @@
 Changes with Apache 2.0.44
 
+  *) Improves the user friendliness of the CacheRoot processing
+     over my last pass. This version avoids the pool allocations
+     but doesn't avoid all of the runtime checks. It no longer
+     terminates during post-config processing. An error is logged
+     once per worker, indicating that the CacheRoot needs to be set.
+     [Paul J. Reder]
+
   *) Fix a bug where we keep files open until the end of a 
      keepalive connection, which can result in:
      (24)Too many open files: file permissions deny server access
diff --git a/STATUS b/STATUS
index b528ce412b8e36bee0a1384e5a6837838df3763a..07c27aea61bf3ab6809aacad27596e6c78107b68 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -1,5 +1,5 @@
 APACHE 2.0 STATUS:                                              -*-text-*-
-Last modified at [$Date: 2002/10/31 05:57:33 $]
+Last modified at [$Date: 2002/11/08 22:42:18 $]
 
 Release:
 
@@ -525,11 +525,9 @@ EXPERIMENTAL MODULES:
 
     * mod_mem_cache/mod_disk_cache: Complete implementing config
       directives (mod_disk_cache: CacheExpiryCheck and GC directives
-      including CacheGc*, CacheSize, CacheMaxFileSize, CacheMinFileSize,
-      and, CacheTimeMargin) (mod_mem_cache: MCacheMaxObjectCount) and
-      (mod_cache: cacheForceCompletion). 
-
-    * mod_cache/mod_mem_cache/mod_disk_cache: Documentation.
+      including CacheGc*, CacheSize, and, CacheTimeMargin)
+      (mod_mem_cache: MCacheMaxObjectCount) and
+      (mod_cache: CacheForceCompletion). 
 
     mod_auth_ldap/util_ldap:
     
index 3648a6a99c6baa1c85016d7c9dc93de17f063790..d37a3321fc9f5be5e3910a41c4ef688511acafb5 100644 (file)
@@ -330,7 +330,11 @@ static int create_entity(cache_handle_t *h, request_rec *r,
     apr_file_t *tmpfile;
 
     if (strcasecmp(type, "disk")) {
-       return DECLINED;
+        return DECLINED;
+    }
+
+    if (conf->cache_root == NULL) {
+        return DECLINED;
     }
 
     if (len < conf->minfs || len > conf->maxfs) {
@@ -382,12 +386,11 @@ static int create_entity(cache_handle_t *h, request_rec *r,
 static int open_entity(cache_handle_t *h, request_rec *r, const char *type, const char *key)
 {
     apr_status_t rc;
+    static int error_logged = 0;
     disk_cache_conf *conf = ap_get_module_config(r->server->module_config, 
                                                  &disk_cache_module);
-    char *data = data_file(r->pool, conf->dirlevels, conf->dirlength, 
-                           conf->cache_root, key);
-    char *headers = header_file(r->pool, conf->dirlevels, conf->dirlength, 
-                                conf->cache_root, key);
+    char *data;
+    char *headers;
     apr_file_t *fd;
     apr_file_t *hfd;
     apr_finfo_t finfo;
@@ -399,9 +402,23 @@ static int open_entity(cache_handle_t *h, request_rec *r, const char *type, cons
 
     /* Look up entity keyed to 'url' */
     if (strcasecmp(type, "disk")) {
-       return DECLINED;
+        return DECLINED;
+    }
+
+    if (conf->cache_root == NULL) {
+        if (!error_logged) {
+            error_logged = 1;
+            ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+                         "disk_cache: Cannot cache files to disk without a CacheRoot specified.");
+        }
+        return DECLINED;
     }
 
+    data = data_file(r->pool, conf->dirlevels, conf->dirlength, 
+                     conf->cache_root, key);
+    headers = header_file(r->pool, conf->dirlevels, conf->dirlength, 
+                          conf->cache_root, key);
+
     /* Open the data file */
     rc = apr_file_open(&fd, data, APR_READ|APR_BINARY, 0, r->pool);
     if (rc != APR_SUCCESS) {
@@ -830,21 +847,6 @@ static const char
     return NULL;
 }
 
-static int disk_cache_post_config(apr_pool_t *p, apr_pool_t *plog,
-                                  apr_pool_t *ptemp, server_rec *s)
-{
-    disk_cache_conf *conf = ap_get_module_config(s->module_config,
-                                                   &disk_cache_module);
-    if (conf->cache_root == NULL) {
-        ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s,
-                     "CacheRoot must be initialized for mod_disk_cache to function.");
-
-        return HTTP_INTERNAL_SERVER_ERROR;
-    }
-
-    return OK;
-}
-
 static const command_rec disk_cache_cmds[] =
 {
     AP_INIT_TAKE1("CacheRoot", set_cache_root, NULL, RSRC_CONF,
@@ -882,7 +884,6 @@ static void disk_cache_register_hook(apr_pool_t *p)
     cache_hook_create_entity(create_entity, NULL, NULL, APR_HOOK_MIDDLE);
     cache_hook_open_entity(open_entity,  NULL, NULL, APR_HOOK_MIDDLE);
 /*    cache_hook_remove_entity(remove_entity, NULL, NULL, APR_HOOK_MIDDLE); */
-    ap_hook_post_config(disk_cache_post_config, NULL, NULL, APR_HOOK_MIDDLE);
 }
 
 module AP_MODULE_DECLARE_DATA disk_cache_module = {