mirror of
https://github.com/apache/httpd.git
synced 2025-08-01 07:26:57 +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:
45
modules/cache/cache_storage.c
vendored
45
modules/cache/cache_storage.c
vendored
@ -74,10 +74,18 @@ int cache_create_entity(cache_request_rec *cache, request_rec *r,
|
|||||||
{
|
{
|
||||||
cache_provider_list *list;
|
cache_provider_list *list;
|
||||||
cache_handle_t *h = apr_pcalloc(r->pool, sizeof(cache_handle_t));
|
cache_handle_t *h = apr_pcalloc(r->pool, sizeof(cache_handle_t));
|
||||||
char *key;
|
|
||||||
apr_status_t rv;
|
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) {
|
if (rv != APR_SUCCESS) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@ -85,7 +93,7 @@ int cache_create_entity(cache_request_rec *cache, request_rec *r,
|
|||||||
list = cache->providers;
|
list = cache->providers;
|
||||||
/* for each specified cache type, delete the URL */
|
/* for each specified cache type, delete the URL */
|
||||||
while (list) {
|
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: {
|
case OK: {
|
||||||
cache->handle = h;
|
cache->handle = h;
|
||||||
cache->provider = list->provider;
|
cache->provider = list->provider;
|
||||||
@ -191,9 +199,17 @@ int cache_select(cache_request_rec *cache, request_rec *r)
|
|||||||
cache_provider_list *list;
|
cache_provider_list *list;
|
||||||
apr_status_t rv;
|
apr_status_t rv;
|
||||||
cache_handle_t *h;
|
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) {
|
if (rv != APR_SUCCESS) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@ -208,7 +224,7 @@ int cache_select(cache_request_rec *cache, request_rec *r)
|
|||||||
list = cache->providers;
|
list = cache->providers;
|
||||||
|
|
||||||
while (list) {
|
while (list) {
|
||||||
switch ((rv = list->provider->open_entity(h, r, key))) {
|
switch ((rv = list->provider->open_entity(h, r, cache->key))) {
|
||||||
case OK: {
|
case OK: {
|
||||||
char *vary = NULL;
|
char *vary = NULL;
|
||||||
int fresh;
|
int fresh;
|
||||||
@ -358,8 +374,8 @@ int cache_select(cache_request_rec *cache, request_rec *r)
|
|||||||
return DECLINED;
|
return DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
apr_status_t cache_generate_key_default(cache_request_rec *cache, request_rec *r,
|
apr_status_t cache_generate_key_default(request_rec *r, apr_pool_t* p,
|
||||||
apr_pool_t* p, char **key)
|
const char **key)
|
||||||
{
|
{
|
||||||
cache_server_conf *conf;
|
cache_server_conf *conf;
|
||||||
char *port_str, *hn, *lcs;
|
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;
|
int i;
|
||||||
char *path, *querystring;
|
char *path, *querystring;
|
||||||
|
|
||||||
if (!cache) {
|
if (*key) {
|
||||||
/* 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) {
|
|
||||||
/*
|
/*
|
||||||
* We have been here before during the processing of this request.
|
* 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;
|
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
|
* resource in the cache under a key where it is never found by the quick
|
||||||
* handler during following requests.
|
* handler during following requests.
|
||||||
*/
|
*/
|
||||||
cache->key = apr_pstrdup(r->pool, *key);
|
|
||||||
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,
|
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,
|
||||||
"cache: Key for entity %s?%s is %s", r->uri,
|
"cache: Key for entity %s?%s is %s", r->uri,
|
||||||
r->parsed_uri.query, *key);
|
r->parsed_uri.query, *key);
|
||||||
|
5
modules/cache/cache_storage.h
vendored
5
modules/cache/cache_storage.h
vendored
@ -31,6 +31,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mod_cache.h"
|
#include "mod_cache.h"
|
||||||
|
#include "cache_util.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cache_storage.c
|
* 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,
|
int cache_create_entity(cache_request_rec *cache, request_rec *r,
|
||||||
apr_off_t size, apr_bucket_brigade *in);
|
apr_off_t size, apr_bucket_brigade *in);
|
||||||
int cache_select(cache_request_rec *cache, request_rec *r);
|
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_status_t cache_generate_key_default(request_rec *r, apr_pool_t* p,
|
||||||
apr_pool_t* p, char **key);
|
const char **key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge in cached headers into the response
|
* Merge in cached headers into the response
|
||||||
|
4
modules/cache/cache_util.c
vendored
4
modules/cache/cache_util.c
vendored
@ -257,7 +257,7 @@ apr_status_t cache_try_lock(cache_server_conf *conf,
|
|||||||
|
|
||||||
/* create the key if it doesn't exist */
|
/* create the key if it doesn't exist */
|
||||||
if (!key) {
|
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 */
|
/* 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 */
|
/* create the key if it doesn't exist */
|
||||||
if (!key) {
|
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 */
|
/* create a hashed filename from the key, and save it for later */
|
||||||
|
33
modules/cache/cache_util.h
vendored
33
modules/cache/cache_util.h
vendored
@ -105,6 +105,39 @@ typedef struct {
|
|||||||
int quick_set;
|
int quick_set;
|
||||||
} cache_server_conf;
|
} 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)
|
* Check the freshness of the cache object per RFC2616 section 13.2 (Expiration Model)
|
||||||
* @param h cache_handle_t
|
* @param h cache_handle_t
|
||||||
|
38
modules/cache/mod_cache.h
vendored
38
modules/cache/mod_cache.h
vendored
@ -133,7 +133,6 @@ struct cache_info {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* cache handle information */
|
/* cache handle information */
|
||||||
|
|
||||||
typedef struct cache_object cache_object_t;
|
typedef struct cache_object cache_object_t;
|
||||||
struct cache_object {
|
struct cache_object {
|
||||||
const char *key;
|
const char *key;
|
||||||
@ -167,39 +166,6 @@ typedef struct {
|
|||||||
apr_status_t (*commit_entity)(cache_handle_t *h, request_rec *r);
|
apr_status_t (*commit_entity)(cache_handle_t *h, request_rec *r);
|
||||||
} cache_provider;
|
} 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 */
|
/* cache_util.c */
|
||||||
/* do a HTTP/1.1 age calculation */
|
/* 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 */
|
/* hooks */
|
||||||
|
|
||||||
APR_DECLARE_OPTIONAL_FN(apr_status_t,
|
APR_DECLARE_OPTIONAL_FN(apr_status_t,
|
||||||
ap_cache_generate_key,
|
ap_cache_generate_key,
|
||||||
(cache_request_rec *cache, request_rec *r,
|
(request_rec *r, apr_pool_t*p, const char **key));
|
||||||
apr_pool_t*p, char **key));
|
|
||||||
|
|
||||||
|
|
||||||
#endif /*MOD_CACHE_H*/
|
#endif /*MOD_CACHE_H*/
|
||||||
|
Reference in New Issue
Block a user