summaryrefslogtreecommitdiffstats
path: root/modules/experimental
diff options
context:
space:
mode:
authorPaul J. Reder <rederpj@apache.org>2002-10-24 17:47:31 +0200
committerPaul J. Reder <rederpj@apache.org>2002-10-24 17:47:31 +0200
commitccb3fa0ac746baf634a6d9e0d7f7716a0c06292c (patch)
tree2b761c535d1d97578e04db28381a0f7c104c89d7 /modules/experimental
parentSwitch to a DNS based certificate rather than an IP based certificate as the (diff)
downloadapache2-ccb3fa0ac746baf634a6d9e0d7f7716a0c06292c.tar.xz
apache2-ccb3fa0ac746baf634a6d9e0d7f7716a0c06292c.zip
Change the CacheRoot processing to check for a required
value at config time. This saves a lot of wasted processing if the mod_disk_cache module is loaded but no CacheRoot was provided. This fix also adds code to log an error and avoid useless pallocs and procesing when the computed cache file name cannot be opened. This also updates the docs accordingly. [Paul J. Reder] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@97290 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/experimental')
-rw-r--r--modules/experimental/mod_disk_cache.c43
1 files changed, 34 insertions, 9 deletions
diff --git a/modules/experimental/mod_disk_cache.c b/modules/experimental/mod_disk_cache.c
index a3c002e7f3..3ad36afe6e 100644
--- a/modules/experimental/mod_disk_cache.c
+++ b/modules/experimental/mod_disk_cache.c
@@ -349,16 +349,24 @@ static int create_entity(cache_handle_t *h, request_rec *r,
rv = apr_file_mktemp(&tmpfile, dobj->tempfile,
APR_CREATE | APR_READ | APR_WRITE | APR_EXCL, r->pool);
- /* Populate the cache handle */
- h->cache_obj = obj;
- h->read_body = &read_body;
- h->read_headers = &read_headers;
- h->write_body = &write_body;
- h->write_headers = &write_headers;
- h->remove_entity = &remove_entity;
+ if (rv == APR_SUCCESS) {
+ /* Populate the cache handle */
+ h->cache_obj = obj;
+ h->read_body = &read_body;
+ h->read_headers = &read_headers;
+ h->write_body = &write_body;
+ h->write_headers = &write_headers;
+ h->remove_entity = &remove_entity;
- ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
- "disk_cache: Caching URL %s", key);
+ ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
+ "disk_cache: Caching URL %s", key);
+ }
+ else {
+ ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
+ "disk_cache: Could not cache URL %s [%d]", key, rv);
+
+ return DECLINED;
+ }
return OK;
}
@@ -812,6 +820,22 @@ 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,
@@ -849,6 +873,7 @@ 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 = {