1
0
mirror of https://github.com/apache/httpd.git synced 2025-07-30 20:03:10 +03:00

Make cache_provider_list and cache_request_rec private by moving them

out of mod_cache.h.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1000247 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Graham Leggett
2010-09-22 21:35:38 +00:00
parent 5c7154ed33
commit fe32c3562b
5 changed files with 64 additions and 61 deletions

View File

@ -74,10 +74,18 @@ int cache_create_entity(cache_request_rec *cache, request_rec *r,
{
cache_provider_list *list;
cache_handle_t *h = apr_pcalloc(r->pool, sizeof(cache_handle_t));
char *key;
apr_status_t rv;
rv = cache_generate_key(cache, r, r->pool, &key);
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");
cache->key = "";
return APR_EGENERAL;
}
rv = cache_generate_key(r, r->pool, &cache->key);
if (rv != APR_SUCCESS) {
return rv;
}
@ -85,7 +93,7 @@ int cache_create_entity(cache_request_rec *cache, request_rec *r,
list = cache->providers;
/* for each specified cache type, delete the URL */
while (list) {
switch (rv = list->provider->create_entity(h, r, key, size, in)) {
switch (rv = list->provider->create_entity(h, r, cache->key, size, in)) {
case OK: {
cache->handle = h;
cache->provider = list->provider;
@ -191,9 +199,17 @@ int cache_select(cache_request_rec *cache, request_rec *r)
cache_provider_list *list;
apr_status_t rv;
cache_handle_t *h;
char *key;
rv = cache_generate_key(cache, r, r->pool, &key);
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");
cache->key = "";
return APR_EGENERAL;
}
rv = cache_generate_key(r, r->pool, &cache->key);
if (rv != APR_SUCCESS) {
return rv;
}
@ -208,7 +224,7 @@ int cache_select(cache_request_rec *cache, request_rec *r)
list = cache->providers;
while (list) {
switch ((rv = list->provider->open_entity(h, r, key))) {
switch ((rv = list->provider->open_entity(h, r, cache->key))) {
case OK: {
char *vary = NULL;
int fresh;
@ -358,8 +374,8 @@ int cache_select(cache_request_rec *cache, request_rec *r)
return DECLINED;
}
apr_status_t cache_generate_key_default(cache_request_rec *cache, request_rec *r,
apr_pool_t* p, char **key)
apr_status_t cache_generate_key_default(request_rec *r, apr_pool_t* p,
const char **key)
{
cache_server_conf *conf;
char *port_str, *hn, *lcs;
@ -367,20 +383,10 @@ apr_status_t cache_generate_key_default(cache_request_rec *cache, request_rec *r
int i;
char *path, *querystring;
if (!cache) {
/* This should never happen */
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
"cache: No cache request information available for key"
" generation");
*key = "";
return APR_EGENERAL;
}
if (cache->key) {
if (*key) {
/*
* We have been here before during the processing of this request.
* So return the key we already have.
*/
*key = apr_pstrdup(p, cache->key);
return APR_SUCCESS;
}
@ -582,7 +588,6 @@ apr_status_t cache_generate_key_default(cache_request_rec *cache, request_rec *r
* resource in the cache under a key where it is never found by the quick
* handler during following requests.
*/
cache->key = apr_pstrdup(r->pool, *key);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,
"cache: Key for entity %s?%s is %s", r->uri,
r->parsed_uri.query, *key);

View File

@ -31,6 +31,7 @@ extern "C" {
#endif
#include "mod_cache.h"
#include "cache_util.h"
/**
* cache_storage.c
@ -39,8 +40,8 @@ int cache_remove_url(cache_request_rec *cache, apr_pool_t *p);
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);
apr_status_t cache_generate_key_default(cache_request_rec *cache, request_rec *r,
apr_pool_t* p, char **key);
apr_status_t cache_generate_key_default(request_rec *r, apr_pool_t* p,
const char **key);
/**
* Merge in cached headers into the response

View File

@ -257,7 +257,7 @@ apr_status_t cache_try_lock(cache_server_conf *conf,
/* create the key if it doesn't exist */
if (!key) {
cache_generate_key(cache, r, r->pool, &key);
cache_generate_key(r, r->pool, &cache->key);
}
/* create a hashed filename from the key, and save it for later */
@ -364,7 +364,7 @@ apr_status_t cache_remove_lock(cache_server_conf *conf,
/* create the key if it doesn't exist */
if (!key) {
cache_generate_key(cache, r, r->pool, &key);
cache_generate_key(r, r->pool, &cache->key);
}
/* create a hashed filename from the key, and save it for later */

View File

@ -105,6 +105,39 @@ typedef struct {
int quick_set;
} cache_server_conf;
/* A linked-list of authn providers. */
typedef struct cache_provider_list cache_provider_list;
struct cache_provider_list {
const char *provider_name;
const cache_provider *provider;
cache_provider_list *next;
};
/* per request cache information */
typedef struct {
cache_provider_list *providers; /* possible cache providers */
const cache_provider *provider; /* current cache provider */
const char *provider_name; /* current cache provider name */
int fresh; /* is the entity fresh? */
cache_handle_t *handle; /* current cache handle */
cache_handle_t *stale_handle; /* stale cache handle */
apr_table_t *stale_headers; /* original request headers. */
int in_checked; /* CACHE_SAVE must cache the entity */
int block_response; /* CACHE_SAVE must block response. */
apr_bucket_brigade *saved_brigade; /* copy of partial response */
apr_off_t saved_size; /* length of saved_brigade */
apr_time_t exp; /* expiration */
apr_time_t lastmod; /* last-modified time */
cache_info *info; /* current cache info */
ap_filter_t *remove_url_filter; /* Enable us to remove the filter */
const char *key; /* The cache key created for this
* request
*/
apr_off_t size; /* the content length from the headers, or -1 */
apr_bucket_brigade *out; /* brigade to reuse for upstream responses */
} cache_request_rec;
/**
* Check the freshness of the cache object per RFC2616 section 13.2 (Expiration Model)
* @param h cache_handle_t

View File

@ -133,7 +133,6 @@ struct cache_info {
};
/* cache handle information */
typedef struct cache_object cache_object_t;
struct cache_object {
const char *key;
@ -167,39 +166,6 @@ typedef struct {
apr_status_t (*commit_entity)(cache_handle_t *h, request_rec *r);
} cache_provider;
/* A linked-list of authn providers. */
typedef struct cache_provider_list cache_provider_list;
struct cache_provider_list {
const char *provider_name;
const cache_provider *provider;
cache_provider_list *next;
};
/* per request cache information */
typedef struct {
cache_provider_list *providers; /* possible cache providers */
const cache_provider *provider; /* current cache provider */
const char *provider_name; /* current cache provider name */
int fresh; /* is the entity fresh? */
cache_handle_t *handle; /* current cache handle */
cache_handle_t *stale_handle; /* stale cache handle */
apr_table_t *stale_headers; /* original request headers. */
int in_checked; /* CACHE_SAVE must cache the entity */
int block_response; /* CACHE_SAVE must block response. */
apr_bucket_brigade *saved_brigade; /* copy of partial response */
apr_off_t saved_size; /* length of saved_brigade */
apr_time_t exp; /* expiration */
apr_time_t lastmod; /* last-modified time */
cache_info *info; /* current cache info */
ap_filter_t *remove_url_filter; /* Enable us to remove the filter */
char *key; /* The cache key created for this
* request
*/
apr_off_t size; /* the content length from the headers, or -1 */
apr_bucket_brigade *out; /* brigade to reuse for upstream responses */
} cache_request_rec;
/* cache_util.c */
/* do a HTTP/1.1 age calculation */
@ -244,11 +210,9 @@ CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_headers_out(request_rec *r);
/* hooks */
APR_DECLARE_OPTIONAL_FN(apr_status_t,
ap_cache_generate_key,
(cache_request_rec *cache, request_rec *r,
apr_pool_t*p, char **key));
(request_rec *r, apr_pool_t*p, const char **key));
#endif /*MOD_CACHE_H*/