From: Graham Leggett Date: Sun, 17 Oct 2010 11:34:03 +0000 (+0000) Subject: Use ap_log_rerror() instead of ap_log_error() across mod_cache and X-Git-Tag: 2.3.9~296 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5d5cd33c52ea9b08207d91ae549b6ef06e468a5;p=thirdparty%2Fapache%2Fhttpd.git Use ap_log_rerror() instead of ap_log_error() across mod_cache and mod_disk_cache. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1023462 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/cache/cache_cache.c b/modules/cache/cache_cache.c index 3b75c3dfd3a..ce518087ee1 100644 --- a/modules/cache/cache_cache.c +++ b/modules/cache/cache_cache.c @@ -123,7 +123,6 @@ void cache_insert(cache_cache_t* c, void *entry) CACHE_HASH_KEY_STRING, NULL); - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL, "Cache Purge of %s",c->key_entry(ejected)); c->current_size -= c->size_entry(ejected); c->free_entry(ejected); c->total_purges++; diff --git a/modules/cache/cache_storage.c b/modules/cache/cache_storage.c index 6ad5a65f06b..66a965c5e0d 100644 --- a/modules/cache/cache_storage.c +++ b/modules/cache/cache_storage.c @@ -31,7 +31,7 @@ extern module AP_MODULE_DECLARE_DATA cache_module; * delete all URL entities from the cache * */ -int cache_remove_url(cache_request_rec *cache, apr_pool_t *p) +int cache_remove_url(cache_request_rec *cache, request_rec *r) { cache_provider_list *list; cache_handle_t *h; @@ -46,12 +46,12 @@ int cache_remove_url(cache_request_rec *cache, apr_pool_t *p) if (!h) { return OK; } - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL, + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "cache: Removing url %s from the cache", h->cache_obj->key); /* for each specified cache type, delete the URL */ while(list) { - list->provider->remove_url(h, p); + list->provider->remove_url(h, r); list = list->next; } return OK; @@ -78,9 +78,9 @@ int cache_create_entity(cache_request_rec *cache, request_rec *r, if (!cache) { /* This should never happen */ - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r->server, - "cache: No cache request information available for key" - " generation"); + ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r, + "cache: No cache request information available for key" + " generation"); return APR_EGENERAL; } @@ -203,9 +203,9 @@ int cache_select(cache_request_rec *cache, request_rec *r) if (!cache) { /* This should never happen */ - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r->server, - "cache: No cache request information available for key" - " generation"); + ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r, + "cache: No cache request information available for key" + " generation"); return DECLINED; } @@ -282,9 +282,8 @@ int cache_select(cache_request_rec *cache, request_rec *r) } else { /* headers do not match, so Vary failed */ - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, - r->server, - "cache_select_url(): Vary header mismatch."); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, + r, "cache_select_url(): Vary header mismatch."); mismatch = 1; } } @@ -318,7 +317,7 @@ int cache_select(cache_request_rec *cache, request_rec *r) r->headers_in); cache->stale_handle = h; - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r, "Cached response for %s isn't fresh. Adding/replacing " "conditional request headers.", r->uri); @@ -381,7 +380,7 @@ int cache_select(cache_request_rec *cache, request_rec *r) /* if Cache-Control: only-if-cached, and not cached, return 504 */ if (cache->control_in.only_if_cached) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r, "cache: 'only-if-cached' requested and no cached entity, " "returning 504 Gateway Timeout for: %s", r->uri); return HTTP_GATEWAY_TIME_OUT; @@ -622,9 +621,9 @@ apr_status_t cache_generate_key_default(request_rec *r, apr_pool_t* p, * resource in the cache under a key where it is never found by the quick * handler during following requests. */ - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL, - "cache: Key for entity %s?%s is %s", r->uri, - r->parsed_uri.query, *key); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r, + "cache: Key for entity %s?%s is %s", r->uri, + r->parsed_uri.query, *key); return APR_SUCCESS; } diff --git a/modules/cache/cache_storage.h b/modules/cache/cache_storage.h index e826334953d..2b67970e1ef 100644 --- a/modules/cache/cache_storage.h +++ b/modules/cache/cache_storage.h @@ -36,7 +36,7 @@ extern "C" { /** * cache_storage.c */ -int cache_remove_url(cache_request_rec *cache, apr_pool_t *p); +int cache_remove_url(cache_request_rec *cache, request_rec *r); int cache_create_entity(cache_request_rec *cache, request_rec *r, apr_off_t size, apr_bucket_brigade *in); int cache_select(cache_request_rec *cache, request_rec *r); diff --git a/modules/cache/cache_util.c b/modules/cache/cache_util.c index beffab7d2ea..f4635877260 100644 --- a/modules/cache/cache_util.c +++ b/modules/cache/cache_util.c @@ -276,9 +276,9 @@ apr_status_t cache_try_lock(cache_server_conf *conf, cache_request_rec *cache, path = apr_pstrcat(r->pool, conf->lockpath, dir, NULL); if (APR_SUCCESS != (status = apr_dir_make_recursive(path, APR_UREAD|APR_UWRITE|APR_UEXECUTE, r->pool))) { - ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server, - "Could not create a cache lock directory: %s", - path); + ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, + "Could not create a cache lock directory: %s", + path); return status; } lockname = apr_pstrcat(r->pool, path, "/", lockname, NULL); @@ -288,16 +288,16 @@ apr_status_t cache_try_lock(cache_server_conf *conf, cache_request_rec *cache, status = apr_stat(&finfo, lockname, APR_FINFO_MTIME | APR_FINFO_NLINK, r->pool); if (!(APR_STATUS_IS_ENOENT(status)) && APR_SUCCESS != status) { - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EEXIST, r->server, - "Could not stat a cache lock file: %s", - lockname); + ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_EEXIST, r, + "Could not stat a cache lock file: %s", + lockname); return status; } if ((status == APR_SUCCESS) && (((now - finfo.mtime) > conf->lockmaxage) || (now < finfo.mtime))) { - ap_log_error(APLOG_MARK, APLOG_INFO, status, r->server, - "Cache lock file for '%s' too old, removing: %s", - r->uri, lockname); + ap_log_rerror(APLOG_MARK, APLOG_INFO, status, r, + "Cache lock file for '%s' too old, removing: %s", + r->uri, lockname); apr_file_remove(lockname, r->pool); } @@ -417,10 +417,10 @@ CACHE_DECLARE(int) ap_cache_check_allowed(cache_request_rec *cache, request_rec return 0; } else { - ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server, - "Incoming request is asking for an uncached version of " - "%s, but we have been configured to ignore it and serve " - "cached content anyway", r->unparsed_uri); + ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, + "Incoming request is asking for an uncached version of " + "%s, but we have been configured to ignore it and serve " + "cached content anyway", r->unparsed_uri); } } @@ -431,10 +431,10 @@ CACHE_DECLARE(int) ap_cache_check_allowed(cache_request_rec *cache, request_rec return 0; } else { - ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server, - "Incoming request is asking for a no-store version of " - "%s, but we have been configured to ignore it and serve " - "cached content anyway", r->unparsed_uri); + ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, + "Incoming request is asking for a no-store version of " + "%s, but we have been configured to ignore it and serve " + "cached content anyway", r->unparsed_uri); } } @@ -506,11 +506,11 @@ int cache_check_freshness(cache_handle_t *h, cache_request_rec *cache, return 0; } - ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server, - "Incoming request is asking for a uncached version of " - "%s, but we have been configured to ignore it and " - "serve a cached response anyway", - r->unparsed_uri); + ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, + "Incoming request is asking for a uncached version of " + "%s, but we have been configured to ignore it and " + "serve a cached response anyway", + r->unparsed_uri); } /* These come from the cached entity. */ @@ -674,18 +674,18 @@ int cache_check_freshness(cache_handle_t *h, cache_request_rec *cache, status = cache_try_lock(conf, cache, r); if (APR_SUCCESS == status) { /* we obtained a lock, follow the stale path */ - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "Cache lock obtained for stale cached URL, " - "revalidating entry: %s", - r->unparsed_uri); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "Cache lock obtained for stale cached URL, " + "revalidating entry: %s", + r->unparsed_uri); return 0; } else if (APR_EEXIST == status) { /* lock already exists, return stale data anyway, with a warning */ - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "Cache already locked for stale cached URL, " - "pretend it is fresh: %s", - r->unparsed_uri); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "Cache already locked for stale cached URL, " + "pretend it is fresh: %s", + r->unparsed_uri); /* make sure we don't stomp on a previous warning */ warn_head = apr_table_get(h->resp_hdrs, "Warning"); @@ -699,10 +699,10 @@ int cache_check_freshness(cache_handle_t *h, cache_request_rec *cache, } else { /* some other error occurred, just treat the object as stale */ - ap_log_error(APLOG_MARK, APLOG_DEBUG, status, r->server, - "Attempt to obtain a cache lock for stale " - "cached URL failed, revalidating entry anyway: %s", - r->unparsed_uri); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, status, r, + "Attempt to obtain a cache lock for stale " + "cached URL failed, revalidating entry anyway: %s", + r->unparsed_uri); return 0; } diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index 667f3fd63e7..2fddca88c08 100644 --- a/modules/cache/mod_cache.c +++ b/modules/cache/mod_cache.c @@ -148,17 +148,16 @@ static int cache_quick_handler(request_rec *r, int lookup) * or not. */ if (r->main) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, - r->server, - "Adding CACHE_SAVE_SUBREQ filter for %s", + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, + r, "Adding CACHE_SAVE_SUBREQ filter for %s", r->uri); cache->save_filter = ap_add_output_filter_handle( cache_save_subreq_filter_handle, cache, r, r->connection); } else { - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, - r->server, "Adding CACHE_SAVE filter for %s", + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, + r, "Adding CACHE_SAVE filter for %s", r->uri); cache->save_filter = ap_add_output_filter_handle( cache_save_filter_handle, cache, r, @@ -167,7 +166,7 @@ static int cache_quick_handler(request_rec *r, int lookup) apr_pool_userdata_setn(cache, CACHE_CTX_KEY, NULL, r->pool); - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r, "Adding CACHE_REMOVE_URL filter for %s", r->uri); @@ -182,16 +181,16 @@ static int cache_quick_handler(request_rec *r, int lookup) cache, r, r->connection); } else { - ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, - r->server, "Cache locked for url, not caching " - "response: %s", r->uri); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, + r, "Cache locked for url, not caching " + "response: %s", r->uri); } } else { if (cache->stale_headers) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, - r->server, "Restoring request headers for %s", - r->uri); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, + r, "Restoring request headers for %s", + r->uri); r->headers_in = cache->stale_headers; } @@ -212,8 +211,8 @@ static int cache_quick_handler(request_rec *r, int lookup) * the headers. */ if (lookup) { if (cache->stale_headers) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, - "Restoring request headers."); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r, + "Restoring request headers."); r->headers_in = cache->stale_headers; } } @@ -413,15 +412,14 @@ static int cache_handler(request_rec *r) * or not. */ if (r->main) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, - r->server, - "Adding CACHE_SAVE_SUBREQ filter for %s", + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, + r, "Adding CACHE_SAVE_SUBREQ filter for %s", r->uri); cache_save_handle = cache_save_subreq_filter_handle; } else { - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, - r->server, "Adding CACHE_SAVE filter for %s", + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, + r, "Adding CACHE_SAVE filter for %s", r->uri); cache_save_handle = cache_save_filter_handle; } @@ -442,8 +440,8 @@ static int cache_handler(request_rec *r) */ if (cache_replace_filter(r->output_filters, cache_filter_handle, cache_save_handle)) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, - r->server, "Replacing CACHE with CACHE_SAVE " + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, + r, "Replacing CACHE with CACHE_SAVE " "filter for %s", r->uri); } @@ -453,7 +451,7 @@ static int cache_handler(request_rec *r) apr_pool_userdata_setn(cache, CACHE_CTX_KEY, NULL, r->pool); - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r, "Adding CACHE_REMOVE_URL filter for %s", r->uri); @@ -469,9 +467,9 @@ static int cache_handler(request_rec *r) } else { - ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, - r->server, "Cache locked for url, not caching " - "response: %s", r->uri); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, + r, "Cache locked for url, not caching " + "response: %s", r->uri); } } else { @@ -516,8 +514,8 @@ static int cache_handler(request_rec *r) * place. */ if (cache_replace_filter(r->output_filters, cache_filter_handle, cache_out_handle)) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, - r->server, "Replacing CACHE with CACHE_OUT filter for %s", + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, + r, "Replacing CACHE with CACHE_OUT filter for %s", r->uri); } @@ -573,14 +571,14 @@ static int cache_out_filter(ap_filter_t *f, apr_bucket_brigade *in) if (!cache) { /* user likely configured CACHE_OUT manually; they should use mod_cache * configuration to do that */ - ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, - "CACHE/CACHE_OUT filter enabled while caching is disabled, ignoring"); + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + "CACHE/CACHE_OUT filter enabled while caching is disabled, ignoring"); ap_remove_output_filter(f); return ap_pass_brigade(f->next, in); } - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, - "cache: running CACHE_OUT filter"); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r, + "cache: running CACHE_OUT filter"); /* clean out any previous response up to EOS, if any */ for (e = APR_BRIGADE_FIRST(in); @@ -601,8 +599,8 @@ static int cache_out_filter(ap_filter_t *f, apr_bucket_brigade *in) /* This filter is done once it has served up its content */ ap_remove_output_filter(f); - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, - "cache: serving %s", r->uri); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r, + "cache: serving %s", r->uri); return ap_pass_brigade(f->next, in); } @@ -636,8 +634,8 @@ static int cache_save_store(ap_filter_t *f, apr_bucket_brigade *in, rv = cache->provider->store_body(cache->handle, f->r, in, cache->out); if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, f->r->server, - "cache: Cache provider's store_body failed!"); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, f->r, + "cache: Cache provider's store_body failed!"); ap_remove_output_filter(f); /* give someone else the chance to cache the file */ @@ -674,10 +672,10 @@ static int cache_save_store(ap_filter_t *f, apr_bucket_brigade *in, /* oops, no data out, but not all data read in either, be * safe and stand down to prevent a spin. */ - ap_log_error(APLOG_MARK, APLOG_WARNING, rv, f->r->server, + ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, f->r, "cache: Cache provider's store_body returned an " - "empty brigade, but didn't consume all of the" - "input brigade, standing down to prevent a spin"); + "empty brigade, but didn't consume all of the" + "input brigade, standing down to prevent a spin"); ap_remove_output_filter(f); /* give someone else the chance to cache the file */ @@ -739,8 +737,8 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) /* user likely configured CACHE_SAVE manually; they should really use * mod_cache configuration to do that */ - ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, - "CACHE/CACHE_SAVE filter enabled while caching is disabled, ignoring"); + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + "CACHE/CACHE_SAVE filter enabled while caching is disabled, ignoring"); ap_remove_output_filter(f); return ap_pass_brigade(f->next, in); } @@ -1057,9 +1055,9 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) } if (reason) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "cache: %s not cached. Reason: %s", r->unparsed_uri, - reason); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "cache: %s not cached. Reason: %s", r->unparsed_uri, + reason); /* we've got a cache miss! tell anyone who cares */ cache_run_cache_status(cache->handle, r, r->headers_out, AP_CACHE_MISS, @@ -1176,14 +1174,14 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) return ap_pass_brigade(f->next, in); } - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "cache: Caching url: %s", r->unparsed_uri); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "cache: Caching url: %s", r->unparsed_uri); /* We are actually caching this response. So it does not * make sense to remove this entity any more. */ - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "cache: Removing CACHE_REMOVE_URL filter."); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "cache: Removing CACHE_REMOVE_URL filter."); ap_remove_output_filter(cache->remove_url_filter); /* @@ -1229,10 +1227,9 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) /* if it's in the future, then replace by date */ lastmod = date; lastmods = dates; - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, - r->server, - "cache: Last modified is in the future, " - "replacing with now"); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, + r, "cache: Last modified is in the future, " + "replacing with now"); } /* if no expiry date then @@ -1362,17 +1359,17 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) * the body it is safe to try and remove the url from the cache. */ if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, r->server, - "cache: updating headers with store_headers failed. " - "Removing cached url."); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, + "cache: updating headers with store_headers failed. " + "Removing cached url."); - rv = cache->provider->remove_url(cache->stale_handle, r->pool); + rv = cache->provider->remove_url(cache->stale_handle, r); if (rv != OK) { /* Probably a mod_disk_cache cache area has been (re)mounted * read-only, or that there is a permissions problem. */ - ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, r->server, - "cache: attempt to remove url from cache unsuccessful."); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, + "cache: attempt to remove url from cache unsuccessful."); } /* we've got a cache conditional hit! tell anyone who cares */ @@ -1397,8 +1394,8 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) } if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, r->server, - "cache: store_headers failed"); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, + "cache: store_headers failed"); /* we've got a cache miss! tell anyone who cares */ cache_run_cache_status(cache->handle, r, r->headers_out, AP_CACHE_MISS, @@ -1451,14 +1448,14 @@ static int cache_remove_url_filter(ap_filter_t *f, apr_bucket_brigade *in) * 1. Remove ourselves * 2. Do nothing and bail out */ - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "cache: CACHE_REMOVE_URL enabled unexpectedly"); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "cache: CACHE_REMOVE_URL enabled unexpectedly"); ap_remove_output_filter(f); return ap_pass_brigade(f->next, in); } /* Now remove this cache entry from the cache */ - cache_remove_url(cache, r->pool); + cache_remove_url(cache, r); /* remove ourselves */ ap_remove_output_filter(f); @@ -1485,9 +1482,9 @@ static int cache_remove_url_filter(ap_filter_t *f, apr_bucket_brigade *in) static int cache_filter(ap_filter_t *f, apr_bucket_brigade *in) { /* we are just a marker, so let's just remove ourselves */ - ap_log_error(APLOG_MARK, APLOG_WARNING, 0, f->r->server, - "cache: CACHE filter was added twice, or was added in quick " - "handler mode and will be ignored."); + ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, f->r, + "cache: CACHE filter was added twice, or was added in quick " + "handler mode and will be ignored."); ap_remove_output_filter(f); return ap_pass_brigade(f->next, in); } diff --git a/modules/cache/mod_cache.h b/modules/cache/mod_cache.h index dc23cd86513..1d234cea43b 100644 --- a/modules/cache/mod_cache.h +++ b/modules/cache/mod_cache.h @@ -131,7 +131,7 @@ typedef struct { const char *urlkey, apr_off_t len, apr_bucket_brigade *bb); int (*open_entity) (cache_handle_t *h, request_rec *r, const char *urlkey); - int (*remove_url) (cache_handle_t *h, apr_pool_t *p); + int (*remove_url) (cache_handle_t *h, request_rec *r); apr_status_t (*commit_entity)(cache_handle_t *h, request_rec *r); } cache_provider; diff --git a/modules/cache/mod_disk_cache.c b/modules/cache/mod_disk_cache.c index 37f01883148..a7c8abe0a1c 100644 --- a/modules/cache/mod_disk_cache.c +++ b/modules/cache/mod_disk_cache.c @@ -173,9 +173,9 @@ static apr_status_t file_cache_el_final(disk_cache_conf *conf, disk_cache_file_t rv = safe_file_rename(conf, file->tempfile, file->file, file->pool); if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_WARNING, rv, r->server, - "disk_cache: rename tempfile to file failed:" - " %s -> %s", file->tempfile, file->file); + ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r, + "disk_cache: rename tempfile to file failed:" + " %s -> %s", file->tempfile, file->file); apr_file_remove(file->tempfile, file->pool); } @@ -350,25 +350,25 @@ static int create_entity(cache_handle_t *h, request_rec *r, const char *key, apr /* we don't support caching of range requests (yet) */ if (r->status == HTTP_PARTIAL_CONTENT) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "disk_cache: URL %s partial content response not cached", - key); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "disk_cache: URL %s partial content response not cached", + key); return DECLINED; } /* Note, len is -1 if unknown so don't trust it too hard */ if (len > dconf->maxfs) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "disk_cache: URL %s failed the size check " - "(%" APR_OFF_T_FMT " > %" APR_OFF_T_FMT ")", - key, len, dconf->maxfs); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "disk_cache: URL %s failed the size check " + "(%" APR_OFF_T_FMT " > %" APR_OFF_T_FMT ")", + key, len, dconf->maxfs); return DECLINED; } if (len >= 0 && len < dconf->minfs) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "disk_cache: URL %s failed the size check " - "(%" APR_OFF_T_FMT " < %" APR_OFF_T_FMT ")", - key, len, dconf->minfs); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "disk_cache: URL %s failed the size check " + "(%" APR_OFF_T_FMT " < %" APR_OFF_T_FMT ")", + key, len, dconf->minfs); return DECLINED; } @@ -425,8 +425,8 @@ static int open_entity(cache_handle_t *h, request_rec *r, const char *key) 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."); + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + "disk_cache: Cannot cache files to disk without a CacheRoot specified."); } return DECLINED; } @@ -465,9 +465,9 @@ static int open_entity(cache_handle_t *h, request_rec *r, const char *key) varray = apr_array_make(r->pool, 5, sizeof(char*)); rc = read_array(r, varray, dobj->vary.fd); if (rc != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, rc, r->server, - "disk_cache: Cannot parse vary header file: %s", - dobj->vary.file); + ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r, + "disk_cache: Cannot parse vary header file: %s", + dobj->vary.file); apr_file_close(dobj->vary.fd); return DECLINED; } @@ -486,9 +486,9 @@ static int open_entity(cache_handle_t *h, request_rec *r, const char *key) } } else if (format != DISK_FORMAT_VERSION) { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, - "disk_cache: File '%s' has a version mismatch. File had version: %d.", - dobj->vary.file, format); + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + "disk_cache: File '%s' has a version mismatch. File had version: %d.", + dobj->vary.file, format); apr_file_close(dobj->vary.fd); return DECLINED; } @@ -522,8 +522,8 @@ static int open_entity(cache_handle_t *h, request_rec *r, const char *key) /* Read the bytes to setup the cache_info fields */ rc = file_cache_recall_mydata(dobj->hdrs.fd, info, dobj, r); if (rc != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, rc, r->server, - "disk_cache: Cannot read header file %s", dobj->hdrs.file); + ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r, + "disk_cache: Cannot read header file %s", dobj->hdrs.file); apr_file_close(dobj->hdrs.fd); return DECLINED; } @@ -532,9 +532,9 @@ static int open_entity(cache_handle_t *h, request_rec *r, const char *key) /* Is this a cached HEAD request? */ if (dobj->disk_info.header_only && !r->header_only) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, - "disk_cache: HEAD request cached, non-HEAD requested, ignoring: %s", - dobj->hdrs.file); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r, + "disk_cache: HEAD request cached, non-HEAD requested, ignoring: %s", + dobj->hdrs.file); return DECLINED; } @@ -550,7 +550,7 @@ static int open_entity(cache_handle_t *h, request_rec *r, const char *key) #endif rc = apr_file_open(&dobj->data.fd, dobj->data.file, flags, 0, r->pool); if (rc != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, rc, r->server, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r, "disk_cache: Cannot open data file %s", dobj->data.file); apr_file_close(dobj->hdrs.fd); return DECLINED; @@ -567,8 +567,8 @@ static int open_entity(cache_handle_t *h, request_rec *r, const char *key) dobj->disk_info.device == finfo.device) { /* Initialize the cache_handle callback functions */ - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "disk_cache: Recalled cached URL info header %s", dobj->name); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "disk_cache: Recalled cached URL info header %s", dobj->name); return OK; } @@ -579,9 +579,9 @@ static int open_entity(cache_handle_t *h, request_rec *r, const char *key) } /* Oh dear, no luck matching header to the body */ - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "disk_cache: Cached URL info header '%s' didn't match body, ignoring this entry", - dobj->name); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "disk_cache: Cached URL info header '%s' didn't match body, ignoring this entry", + dobj->name); return DECLINED; } @@ -593,7 +593,7 @@ static int remove_entity(cache_handle_t *h) return OK; } -static int remove_url(cache_handle_t *h, apr_pool_t *p) +static int remove_url(cache_handle_t *h, request_rec *r) { apr_status_t rc; disk_cache_object_t *dobj; @@ -606,34 +606,34 @@ static int remove_url(cache_handle_t *h, apr_pool_t *p) /* Delete headers file */ if (dobj->hdrs.file) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL, - "disk_cache: Deleting %s from cache.", dobj->hdrs.file); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "disk_cache: Deleting %s from cache.", dobj->hdrs.file); - rc = apr_file_remove(dobj->hdrs.file, p); + rc = apr_file_remove(dobj->hdrs.file, r->pool); if ((rc != APR_SUCCESS) && !APR_STATUS_IS_ENOENT(rc)) { /* Will only result in an output if httpd is started with -e debug. * For reason see log_error_core for the case s == NULL. */ - ap_log_error(APLOG_MARK, APLOG_DEBUG, rc, NULL, - "disk_cache: Failed to delete headers file %s from cache.", - dobj->hdrs.file); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rc, r, + "disk_cache: Failed to delete headers file %s from cache.", + dobj->hdrs.file); return DECLINED; } } /* Delete data file */ if (dobj->data.file) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL, - "disk_cache: Deleting %s from cache.", dobj->data.file); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "disk_cache: Deleting %s from cache.", dobj->data.file); - rc = apr_file_remove(dobj->data.file, p); + rc = apr_file_remove(dobj->data.file, r->pool); if ((rc != APR_SUCCESS) && !APR_STATUS_IS_ENOENT(rc)) { /* Will only result in an output if httpd is started with -e debug. * For reason see log_error_core for the case s == NULL. */ - ap_log_error(APLOG_MARK, APLOG_DEBUG, rc, NULL, - "disk_cache: Failed to delete data file %s from cache.", - dobj->data.file); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rc, r, + "disk_cache: Failed to delete data file %s from cache.", + dobj->data.file); return DECLINED; } } @@ -646,7 +646,7 @@ static int remove_url(cache_handle_t *h, apr_pool_t *p) if (str_to_copy) { char *dir, *slash, *q; - dir = apr_pstrdup(p, str_to_copy); + dir = apr_pstrdup(r->pool, str_to_copy); /* remove filename */ slash = strrchr(dir, '/'); @@ -663,11 +663,11 @@ static int remove_url(cache_handle_t *h, apr_pool_t *p) * we won't either delete or go above our cache root. */ for (q = dir + dobj->root_len; *q ; ) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL, - "disk_cache: Deleting directory %s from cache", - dir); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "disk_cache: Deleting directory %s from cache", + dir); - rc = apr_dir_remove(dir, p); + rc = apr_dir_remove(dir, r->pool); if (rc != APR_SUCCESS && !APR_STATUS_IS_ENOENT(rc)) { break; } @@ -802,9 +802,9 @@ static apr_status_t read_table(cache_handle_t *handle, request_rec *r, ++maybeASCII; } if (maybeASCII > maybeEBCDIC) { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, - "CGI Interface Error: Script headers apparently ASCII: (CGI = %s)", - r->filename); + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + "CGI Interface Error: Script headers apparently ASCII: (CGI = %s)", + r->filename); inbytes_left = outbytes_left = cp - w; apr_xlate_conv_buffer(ap_hdrs_from_ascii, w, &inbytes_left, w, &outbytes_left); @@ -841,8 +841,8 @@ static apr_status_t recall_headers(cache_handle_t *h, request_rec *r) /* This case should not happen... */ if (!dobj->hdrs.fd) { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, - "disk_cache: recalling headers; but no header fd for %s", dobj->name); + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + "disk_cache: recalling headers; but no header fd for %s", dobj->name); return APR_NOTFOUND; } @@ -855,8 +855,8 @@ static apr_status_t recall_headers(cache_handle_t *h, request_rec *r) apr_file_close(dobj->hdrs.fd); - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "disk_cache: Recalled headers for URL %s", dobj->name); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "disk_cache: Recalled headers for URL %s", dobj->name); return APR_SUCCESS; } @@ -960,9 +960,9 @@ static apr_status_t write_headers(cache_handle_t *h, request_rec *r) dobj->vary.pool); if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_WARNING, rv, r->server, - "disk_cache: could not create temp file %s", - dobj->vary.tempfile); + ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r, + "disk_cache: could not create temp file %s", + dobj->vary.tempfile); return rv; } @@ -993,9 +993,9 @@ static apr_status_t write_headers(cache_handle_t *h, request_rec *r) APR_BUFFERED | APR_EXCL, dobj->hdrs.pool); if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_WARNING, rv, r->server, - "disk_cache: could not create temp file %s", - dobj->hdrs.tempfile); + ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r, + "disk_cache: could not create temp file %s", + dobj->hdrs.tempfile); return rv; } @@ -1022,9 +1022,9 @@ static apr_status_t write_headers(cache_handle_t *h, request_rec *r) rv = apr_file_writev(dobj->hdrs.tempfd, (const struct iovec *) &iov, 2, &amt); if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_WARNING, rv, r->server, - "disk_cache: could not write info to header file %s", - dobj->hdrs.tempfile); + ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r, + "disk_cache: could not write info to header file %s", + dobj->hdrs.tempfile); apr_file_close(dobj->hdrs.tempfd); return rv; } @@ -1032,9 +1032,9 @@ static apr_status_t write_headers(cache_handle_t *h, request_rec *r) if (dobj->headers_out) { rv = store_table(dobj->hdrs.tempfd, dobj->headers_out); if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_WARNING, rv, r->server, - "disk_cache: could not write out-headers to header file %s", - dobj->hdrs.tempfile); + ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r, + "disk_cache: could not write out-headers to header file %s", + dobj->hdrs.tempfile); apr_file_close(dobj->hdrs.tempfd); return rv; } @@ -1045,9 +1045,9 @@ static apr_status_t write_headers(cache_handle_t *h, request_rec *r) if (dobj->headers_in) { rv = store_table(dobj->hdrs.tempfd, dobj->headers_in); if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_WARNING, rv, r->server, - "disk_cache: could not write in-headers to header file %s", - dobj->hdrs.tempfile); + ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r, + "disk_cache: could not write in-headers to header file %s", + dobj->hdrs.tempfile); apr_file_close(dobj->hdrs.tempfd); return rv; } @@ -1124,9 +1124,9 @@ static apr_status_t store_body(cache_handle_t *h, request_rec *r, APR_BUCKET_REMOVE(e); APR_BRIGADE_INSERT_TAIL(dobj->bb, e); if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, - "disk_cache: Error when reading bucket for URL %s", - h->cache_obj->key); + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + "disk_cache: Error when reading bucket for URL %s", + h->cache_obj->key); /* Remove the intermediate cache file and return non-APR_SUCCESS */ apr_pool_destroy(dobj->data.pool); APR_BRIGADE_CONCAT(out, dobj->bb); @@ -1163,9 +1163,9 @@ static apr_status_t store_body(cache_handle_t *h, request_rec *r, /* write to the cache, leave if we fail */ rv = apr_file_write_full(dobj->data.tempfd, str, length, &written); if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, - "disk_cache: Error when writing cache file for URL %s", - h->cache_obj->key); + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + "disk_cache: Error when writing cache file for URL %s", + h->cache_obj->key); /* Remove the intermediate cache file and return non-APR_SUCCESS */ apr_pool_destroy(dobj->data.pool); APR_BRIGADE_CONCAT(out, dobj->bb); @@ -1173,10 +1173,10 @@ static apr_status_t store_body(cache_handle_t *h, request_rec *r, } dobj->file_size += written; if (dobj->file_size > dconf->maxfs) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "disk_cache: URL %s failed the size check " - "(%" APR_OFF_T_FMT ">%" APR_OFF_T_FMT ")", - h->cache_obj->key, dobj->file_size, dconf->maxfs); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "disk_cache: URL %s failed the size check " + "(%" APR_OFF_T_FMT ">%" APR_OFF_T_FMT ")", + h->cache_obj->key, dobj->file_size, dconf->maxfs); /* Remove the intermediate cache file and return non-APR_SUCCESS */ apr_pool_destroy(dobj->data.pool); APR_BRIGADE_CONCAT(out, dobj->bb); @@ -1213,19 +1213,19 @@ static apr_status_t store_body(cache_handle_t *h, request_rec *r, } if (r->connection->aborted || r->no_cache) { - ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server, - "disk_cache: Discarding body for URL %s " - "because connection has been aborted.", - h->cache_obj->key); + ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, + "disk_cache: Discarding body for URL %s " + "because connection has been aborted.", + h->cache_obj->key); /* Remove the intermediate cache file and return non-APR_SUCCESS */ apr_pool_destroy(dobj->data.pool); return APR_EGENERAL; } if (dobj->file_size < dconf->minfs) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "disk_cache: URL %s failed the size check " - "(%" APR_OFF_T_FMT "<%" APR_OFF_T_FMT ")", - h->cache_obj->key, dobj->file_size, dconf->minfs); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "disk_cache: URL %s failed the size check " + "(%" APR_OFF_T_FMT "<%" APR_OFF_T_FMT ")", + h->cache_obj->key, dobj->file_size, dconf->minfs); /* Remove the intermediate cache file and return non-APR_SUCCESS */ apr_pool_destroy(dobj->data.pool); return APR_EGENERAL; @@ -1233,9 +1233,9 @@ static apr_status_t store_body(cache_handle_t *h, request_rec *r, if (cl_header) { apr_int64_t cl = apr_atoi64(cl_header); if ((errno == 0) && (dobj->file_size != cl)) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "disk_cache: URL %s didn't receive complete response, not caching", - h->cache_obj->key); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "disk_cache: URL %s didn't receive complete response, not caching", + h->cache_obj->key); /* Remove the intermediate cache file and return non-APR_SUCCESS */ apr_pool_destroy(dobj->data.pool); return APR_EGENERAL; @@ -1271,15 +1271,15 @@ static apr_status_t commit_entity(cache_handle_t *h, request_rec *r) /* remove the cached items completely on any failure */ if (APR_SUCCESS != rv) { - remove_url(h, r->pool); - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "disk_cache: commit_entity: URL '%s' not cached due to earlier disk error.", - dobj->name); + remove_url(h, r); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "disk_cache: commit_entity: URL '%s' not cached due to earlier disk error.", + dobj->name); } else { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "disk_cache: commit_entity: Headers and body for URL %s cached.", - dobj->name); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "disk_cache: commit_entity: Headers and body for URL %s cached.", + dobj->name); } apr_pool_destroy(dobj->data.pool);