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;
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);