From: Bill Stoddard Date: Thu, 18 Jul 2002 01:29:29 +0000 (+0000) Subject: Do some sanity checking on the cache config directives. X-Git-Tag: 2.0.40~192 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e8235537a1571f11f838b92f386fd2df629dad57;p=apache Do some sanity checking on the cache config directives. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96109 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/experimental/mod_mem_cache.c b/modules/experimental/mod_mem_cache.c index afd14e2bc0..f3f9c2bc2d 100644 --- a/modules/experimental/mod_mem_cache.c +++ b/modules/experimental/mod_mem_cache.c @@ -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);