You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mi...@apache.org on 2010/09/22 23:35:38 UTC
svn commit: r1000247 - in /httpd/httpd/trunk/modules/cache: cache_storage.c
cache_storage.h cache_util.c cache_util.h mod_cache.h
Author: minfrin
Date: Wed Sep 22 21:35:38 2010
New Revision: 1000247
URL: http://svn.apache.org/viewvc?rev=1000247&view=rev
Log:
Make cache_provider_list and cache_request_rec private by moving them
out of mod_cache.h.
Modified:
httpd/httpd/trunk/modules/cache/cache_storage.c
httpd/httpd/trunk/modules/cache/cache_storage.h
httpd/httpd/trunk/modules/cache/cache_util.c
httpd/httpd/trunk/modules/cache/cache_util.h
httpd/httpd/trunk/modules/cache/mod_cache.h
Modified: httpd/httpd/trunk/modules/cache/cache_storage.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_storage.c?rev=1000247&r1=1000246&r2=1000247&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_storage.c (original)
+++ httpd/httpd/trunk/modules/cache/cache_storage.c Wed Sep 22 21:35:38 2010
@@ -74,10 +74,18 @@ int cache_create_entity(cache_request_re
{
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_re
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 *cach
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 *cach
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 *cach
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(
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(
* 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);
Modified: httpd/httpd/trunk/modules/cache/cache_storage.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_storage.h?rev=1000247&r1=1000246&r2=1000247&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_storage.h (original)
+++ httpd/httpd/trunk/modules/cache/cache_storage.h Wed Sep 22 21:35:38 2010
@@ -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 *
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
Modified: httpd/httpd/trunk/modules/cache/cache_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_util.c?rev=1000247&r1=1000246&r2=1000247&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_util.c (original)
+++ httpd/httpd/trunk/modules/cache/cache_util.c Wed Sep 22 21:35:38 2010
@@ -257,7 +257,7 @@ apr_status_t cache_try_lock(cache_server
/* 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_ser
/* 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 */
Modified: httpd/httpd/trunk/modules/cache/cache_util.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_util.h?rev=1000247&r1=1000246&r2=1000247&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_util.h (original)
+++ httpd/httpd/trunk/modules/cache/cache_util.h Wed Sep 22 21:35:38 2010
@@ -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
Modified: httpd/httpd/trunk/modules/cache/mod_cache.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache.h?rev=1000247&r1=1000246&r2=1000247&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.h (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.h Wed Sep 22 21:35:38 2010
@@ -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_cac
/* 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*/
Re: svn commit: r1000247 - in /httpd/httpd/trunk/modules/cache: cache_storage.c cache_storage.h cache_util.c cache_util.h mod_cache.h
Posted by Graham Leggett <mi...@sharp.fm>.
On 23 Sep 2010, at 7:44 AM, Ruediger Pluem wrote:
>> - 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 = "";
>
> This creates a Segfault. We know that cache == NULL.
Indeed. Fixed in r1000395.
Regards,
Graham
--
Re: svn commit: r1000247 - in /httpd/httpd/trunk/modules/cache: cache_storage.c
cache_storage.h cache_util.c cache_util.h mod_cache.h
Posted by Ruediger Pluem <rp...@apache.org>.
On 09/22/2010 11:35 PM, minfrin@apache.org wrote:
> Author: minfrin
> Date: Wed Sep 22 21:35:38 2010
> New Revision: 1000247
>
> URL: http://svn.apache.org/viewvc?rev=1000247&view=rev
> Log:
> Make cache_provider_list and cache_request_rec private by moving them
> out of mod_cache.h.
>
> Modified:
> httpd/httpd/trunk/modules/cache/cache_storage.c
> httpd/httpd/trunk/modules/cache/cache_storage.h
> httpd/httpd/trunk/modules/cache/cache_util.c
> httpd/httpd/trunk/modules/cache/cache_util.h
> httpd/httpd/trunk/modules/cache/mod_cache.h
>
> Modified: httpd/httpd/trunk/modules/cache/cache_storage.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_storage.c?rev=1000247&r1=1000246&r2=1000247&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/modules/cache/cache_storage.c (original)
> +++ httpd/httpd/trunk/modules/cache/cache_storage.c Wed Sep 22 21:35:38 2010
> @@ -74,10 +74,18 @@ int cache_create_entity(cache_request_re
> {
> 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 = "";
This creates a Segfault. We know that cache == NULL.
> + return APR_EGENERAL;
> + }
> +
> + rv = cache_generate_key(r, r->pool, &cache->key);
> if (rv != APR_SUCCESS) {
> return rv;
> }
> @@ -191,9 +199,17 @@ int cache_select(cache_request_rec *cach
> 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 = "";
This creates a Segfault. We know that cache == NULL.
> + return APR_EGENERAL;
> + }
> +
> + rv = cache_generate_key(r, r->pool, &cache->key);
> if (rv != APR_SUCCESS) {
> return rv;
> }
Regards
RĂ¼diger