]> granicus.if.org Git - apache/commitdiff
Do some sanity checking on the cache config directives.
authorBill Stoddard <stoddard@apache.org>
Thu, 18 Jul 2002 01:29:29 +0000 (01:29 +0000)
committerBill Stoddard <stoddard@apache.org>
Thu, 18 Jul 2002 01:29:29 +0000 (01:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96109 13f79535-47bb-0310-9956-ffa450edef68

modules/experimental/mod_mem_cache.c

index afd14e2bc0f870ab0dfdb8c2bd2c7b6ce3e3c598..f3f9c2bc2dfd9723153b44bde1a9a24b4b8dfa17 100644 (file)
@@ -447,35 +447,24 @@ static int create_entity(cache_handle_t *h, request_rec *r,
         return DECLINED;
     }
 
-    /*
-     * TODO: Get smarter about managing the cache size. If the cache is 
-     * full, we need to garbage collect stale/infrequently referenced
-     * objects.
-     * we have a self-sizing cache now
-    if (sconf->object_cnt >= sconf->max_object_cnt) {
+    /* In principle, we should be able to dispense with the cache_size checks
+     * when caching open file descriptors.  However, code in cache_insert() and 
+     * other places does not make the distinction whether a file's content or
+     * descriptor is being cached. For now, just do all the same size checks
+     * regardless of what we are caching.
+     */
+    if (len < sconf->min_cache_object_size || 
+        len > sconf->max_cache_object_size) {
+        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                     "cache_mem: URL %s failed the size check, "
+                     "or is incomplete", 
+                     key);
         return DECLINED;
     }
-     */
-    if (type_e == CACHE_TYPE_HEAP) {
-        /* We can safely ignore these measures when caching open fds */
-        if (len < sconf->min_cache_object_size || 
-            len > sconf->max_cache_object_size) {
-            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
-                         "cache_mem: URL %s failed the size check, "
-                         "or is incomplete", 
-                         key);
-            return DECLINED;
-        }
-        /*
-         * not needed now we have a self-sizing cache.
-        if ((sconf->cache_size + len) > sconf->max_cache_size) {
-            return DECLINED;
-        }
-        */
-    } else {
-        /* CACHE_TYPE_FILE is only valid for local content 
-         * handled by the default handler? 
-         * This is not the right check...
+    if (type_e == CACHE_TYPE_FILE) {
+        /* CACHE_TYPE_FILE is only valid for local content handled by the 
+         * default handler. Need a better way to check if the file is
+         * local or not.
          */
         if (!r->filename) {
             return DECLINED;
@@ -1012,6 +1001,18 @@ static int mem_cache_post_config(apr_pool_t *p, apr_pool_t *plog,
                                  apr_pool_t *ptemp, server_rec *s)
 {
     int threaded_mpm;
+
+    /* Sanity check the cache configuration */
+    if (sconf->min_cache_object_size >= sconf->max_cache_object_size) {
+        ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s,
+                     "MCacheMaxObjectSize must be greater than MCacheMinObjectSize");
+        return DONE;
+    }
+    if (sconf->max_cache_object_size >= sconf->max_cache_size) {
+        ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s,
+                     "MCacheSize must be greater than MCacheMaxObjectSize");
+        return DONE;
+    }
     ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded_mpm);
     if (threaded_mpm) {
         apr_thread_mutex_create(&sconf->lock, APR_THREAD_MUTEX_DEFAULT, p);