From cc0d6707c65d124a4f53b793a4328f38fadab894 Mon Sep 17 00:00:00 2001 From: Justin Erenkrantz Date: Tue, 3 Aug 2004 08:20:21 +0000 Subject: [PATCH] Avoid confusion when reading mod_cache code. write_ and read_ often imply network code; store_ and recall_ are more understandable prefixes in this context. Reviewed by: Roy Fielding, Cliff Woolley git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@104458 13f79535-47bb-0310-9956-ffa450edef68 --- modules/experimental/cache_storage.c | 22 +++++++++------ modules/experimental/mod_cache.c | 10 +++---- modules/experimental/mod_cache.h | 16 +++++------ modules/experimental/mod_disk_cache.c | 40 +++++++++++++-------------- modules/experimental/mod_mem_cache.c | 36 ++++++++++++------------ 5 files changed, 64 insertions(+), 60 deletions(-) diff --git a/modules/experimental/cache_storage.c b/modules/experimental/cache_storage.c index c0d6f28619..6c0bf9f066 100644 --- a/modules/experimental/cache_storage.c +++ b/modules/experimental/cache_storage.c @@ -145,7 +145,7 @@ int cache_select_url(request_rec *r, const char *types, char *url) case OK: { char *vary = NULL; const char *varyhdr = NULL; - if (cache_read_entity_headers(h, r) != APR_SUCCESS) { + if (cache_recall_entity_headers(h, r) != APR_SUCCESS) { /* TODO: Handle this error */ return DECLINED; } @@ -222,24 +222,26 @@ int cache_select_url(request_rec *r, const char *types, char *url) return DECLINED; } -apr_status_t cache_write_entity_headers(cache_handle_t *h, +apr_status_t cache_store_entity_headers(cache_handle_t *h, request_rec *r, cache_info *info) { - return (h->write_headers(h, r, info)); + return (h->store_headers(h, r, info)); } -apr_status_t cache_write_entity_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b) + +apr_status_t cache_store_entity_body(cache_handle_t *h, request_rec *r, + apr_bucket_brigade *b) { - return (h->write_body(h, r, b)); + return (h->store_body(h, r, b)); } -apr_status_t cache_read_entity_headers(cache_handle_t *h, request_rec *r) +apr_status_t cache_recall_entity_headers(cache_handle_t *h, request_rec *r) { apr_status_t rv; cache_info *info = &(h->cache_obj->info); /* Build the header table from info in the info struct */ - rv = h->read_headers(h, r); + rv = h->recall_headers(h, r); if (rv != APR_SUCCESS) { return rv; } @@ -248,9 +250,11 @@ apr_status_t cache_read_entity_headers(cache_handle_t *h, request_rec *r) return APR_SUCCESS; } -apr_status_t cache_read_entity_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *b) + +apr_status_t cache_recall_entity_body(cache_handle_t *h, apr_pool_t *p, + apr_bucket_brigade *b) { - return (h->read_body(h, p, b)); + return (h->recall_body(h, p, b)); } apr_status_t cache_generate_key_default( request_rec *r, apr_pool_t*p, char**key ) diff --git a/modules/experimental/mod_cache.c b/modules/experimental/mod_cache.c index f53f2d0579..7150a7641b 100644 --- a/modules/experimental/mod_cache.c +++ b/modules/experimental/mod_cache.c @@ -260,8 +260,8 @@ static int cache_out_filter(ap_filter_t *f, apr_bucket_brigade *bb) ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, "cache: running CACHE_OUT filter"); - /* cache_read_entity_headers() was called in cache_select_url() */ - cache_read_entity_body(cache->handle, r->pool, bb); + /* cache_recall_entity_headers() was called in cache_select_url() */ + cache_recall_entity_body(cache->handle, r->pool, bb); /* This filter is done once it has served up its content */ ap_remove_output_filter(f); @@ -369,7 +369,7 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) /* pass the brigades into the cache, then pass them * up the filter stack */ - rv = cache_write_entity_body(cache->handle, r, in); + rv = cache_store_entity_body(cache->handle, r, in); if (rv != APR_SUCCESS) { ap_remove_output_filter(f); } @@ -708,9 +708,9 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) /* * Write away header information to cache. */ - rv = cache_write_entity_headers(cache->handle, r, info); + rv = cache_store_entity_headers(cache->handle, r, info); if (rv == APR_SUCCESS) { - rv = cache_write_entity_body(cache->handle, r, in); + rv = cache_store_entity_body(cache->handle, r, in); } if (rv != APR_SUCCESS) { ap_remove_output_filter(f); diff --git a/modules/experimental/mod_cache.h b/modules/experimental/mod_cache.h index 120db0cc5c..b491f9a117 100644 --- a/modules/experimental/mod_cache.h +++ b/modules/experimental/mod_cache.h @@ -178,10 +178,10 @@ typedef struct cache_handle cache_handle_t; struct cache_handle { cache_object_t *cache_obj; int (*remove_entity) (cache_handle_t *h); - apr_status_t (*write_headers)(cache_handle_t *h, request_rec *r, cache_info *i); - apr_status_t (*write_body)(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b); - apr_status_t (*read_headers) (cache_handle_t *h, request_rec *r); - apr_status_t (*read_body) (cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb); + apr_status_t (*store_headers)(cache_handle_t *h, request_rec *r, cache_info *i); + apr_status_t (*store_body)(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b); + apr_status_t (*recall_headers) (cache_handle_t *h, request_rec *r); + apr_status_t (*recall_body) (cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb); apr_table_t *req_hdrs; /* These are the original request headers */ }; @@ -242,11 +242,11 @@ apr_status_t cache_generate_key_default( request_rec *r, apr_pool_t*p, char**key */ const char* cache_create_key( request_rec*r ); -apr_status_t cache_write_entity_headers(cache_handle_t *h, request_rec *r, cache_info *info); -apr_status_t cache_write_entity_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *bb); +apr_status_t cache_store_entity_headers(cache_handle_t *h, request_rec *r, cache_info *info); +apr_status_t cache_store_entity_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *bb); -apr_status_t cache_read_entity_headers(cache_handle_t *h, request_rec *r); -apr_status_t cache_read_entity_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb); +apr_status_t cache_recall_entity_headers(cache_handle_t *h, request_rec *r); +apr_status_t cache_recall_entity_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb); /* hooks */ diff --git a/modules/experimental/mod_disk_cache.c b/modules/experimental/mod_disk_cache.c index 3797667f15..6366a3698d 100644 --- a/modules/experimental/mod_disk_cache.c +++ b/modules/experimental/mod_disk_cache.c @@ -78,10 +78,10 @@ module AP_MODULE_DECLARE_DATA disk_cache_module; /* Forward declarations */ static int remove_entity(cache_handle_t *h); -static apr_status_t write_headers(cache_handle_t *h, request_rec *r, cache_info *i); -static apr_status_t write_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b); -static apr_status_t read_headers(cache_handle_t *h, request_rec *r); -static apr_status_t read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb); +static apr_status_t store_headers(cache_handle_t *h, request_rec *r, cache_info *i); +static apr_status_t store_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b); +static apr_status_t recall_headers(cache_handle_t *h, request_rec *r); +static apr_status_t recall_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb); /* * Local static functions @@ -186,7 +186,7 @@ static apr_status_t file_cache_errorcleanup(disk_cache_object_t *dobj, request_r * file for an ap_cache_el, this state information will be read * and written transparent to clients of this module */ -static int file_cache_read_mydata(apr_file_t *fd, cache_info *info, +static int file_cache_recall_mydata(apr_file_t *fd, cache_info *info, disk_cache_object_t *dobj) { apr_status_t rv; @@ -243,7 +243,7 @@ static int file_cache_read_mydata(apr_file_t *fd, cache_info *info, return APR_SUCCESS; } -static int file_cache_write_mydata(apr_file_t *fd , cache_handle_t *h, request_rec *r) +static int file_cache_store_mydata(apr_file_t *fd , cache_handle_t *h, request_rec *r) { apr_status_t rc; char *buf; @@ -337,10 +337,10 @@ static int create_entity(cache_handle_t *h, request_rec *r, 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->recall_body = &recall_body; + h->recall_headers = &recall_headers; + h->store_body = &store_body; + h->store_headers = &store_headers; h->remove_entity = &remove_entity; ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server, @@ -430,17 +430,17 @@ static int open_entity(cache_handle_t *h, request_rec *r, const char *type, cons } /* Read the bytes to setup the cache_info fields */ - rc = file_cache_read_mydata(hfd, info, dobj); + rc = file_cache_recall_mydata(hfd, info, dobj); if (rc != APR_SUCCESS) { /* XXX log message */ return DECLINED; } /* Initialize the cache_handle callback functions */ - h->read_body = &read_body; - h->read_headers = &read_headers; - h->write_body = &write_body; - h->write_headers = &write_headers; + h->recall_body = &recall_body; + h->recall_headers = &recall_headers; + h->store_body = &store_body; + h->store_headers = &store_headers; h->remove_entity = &remove_entity; ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server, @@ -462,7 +462,7 @@ static int remove_entity(cache_handle_t *h) * @@@: XXX: FIXME: currently the headers are passed thru un-merged. * Is that okay, or should they be collapsed where possible? */ -static apr_status_t read_headers(cache_handle_t *h, request_rec *r) +static apr_status_t recall_headers(cache_handle_t *h, request_rec *r) { apr_status_t rv; char urlbuff[1034]; @@ -523,7 +523,7 @@ static apr_status_t read_headers(cache_handle_t *h, request_rec *r) return APR_SUCCESS; } -static apr_status_t read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb) +static apr_status_t recall_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb) { apr_bucket *e; disk_cache_object_t *dobj = (disk_cache_object_t*) h->cache_obj->vobj; @@ -537,7 +537,7 @@ static apr_status_t read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_briga return APR_SUCCESS; } -static apr_status_t write_headers(cache_handle_t *h, request_rec *r, cache_info *info) +static apr_status_t store_headers(cache_handle_t *h, request_rec *r, cache_info *info) { disk_cache_conf *conf = ap_get_module_config(r->server->module_config, &disk_cache_module); @@ -578,7 +578,7 @@ static apr_status_t write_headers(cache_handle_t *h, request_rec *r, cache_info hfd = dobj->hfd; dobj->name = h->cache_obj->key; - file_cache_write_mydata(dobj->hfd, h, r); + file_cache_store_mydata(dobj->hfd, h, r); if (r->headers_out) { int i; @@ -645,7 +645,7 @@ static apr_status_t write_headers(cache_handle_t *h, request_rec *r, cache_info return APR_SUCCESS; } -static apr_status_t write_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b) +static apr_status_t store_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b) { apr_bucket *e; apr_status_t rv; diff --git a/modules/experimental/mod_mem_cache.c b/modules/experimental/mod_mem_cache.c index 150a6cbc12..13936026ac 100644 --- a/modules/experimental/mod_mem_cache.c +++ b/modules/experimental/mod_mem_cache.c @@ -89,10 +89,10 @@ static mem_cache_conf *sconf; /* Forward declarations */ static int remove_entity(cache_handle_t *h); -static apr_status_t write_headers(cache_handle_t *h, request_rec *r, cache_info *i); -static apr_status_t write_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b); -static apr_status_t read_headers(cache_handle_t *h, request_rec *r); -static apr_status_t read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb); +static apr_status_t store_headers(cache_handle_t *h, request_rec *r, cache_info *i); +static apr_status_t store_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b); +static apr_status_t recall_headers(cache_handle_t *h, request_rec *r); +static apr_status_t recall_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb); static void cleanup_cache_object(cache_object_t *obj); @@ -372,7 +372,7 @@ static int create_entity(cache_handle_t *h, request_rec *r, if (len == -1) { /* Caching a streaming response. Assume the response is * less than or equal to max_streaming_buffer_size. We will - * correct all the cache size counters in write_body once + * correct all the cache size counters in store_body once * we know exactly know how much we are caching. */ len = sconf->max_streaming_buffer_size; @@ -471,10 +471,10 @@ static int create_entity(cache_handle_t *h, request_rec *r, /* 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->recall_body = &recall_body; + h->recall_headers = &recall_headers; + h->store_body = &store_body; + h->store_headers = &store_headers; h->remove_entity = &remove_entity; return OK; @@ -526,13 +526,13 @@ static int open_entity(cache_handle_t *h, request_rec *r, const char *type, cons } /* Initialize the cache_handle */ - h->read_body = &read_body; - h->read_headers = &read_headers; - h->write_body = &write_body; - h->write_headers = &write_headers; + h->recall_body = &recall_body; + h->recall_headers = &recall_headers; + h->store_body = &store_body; + h->store_headers = &store_headers; h->remove_entity = &remove_entity; h->cache_obj = obj; - h->req_hdrs = NULL; /* Pick these up in read_headers() */ + h->req_hdrs = NULL; /* Pick these up in recall_headers() */ return OK; } @@ -665,7 +665,7 @@ static int remove_url(const char *type, const char *key) return OK; } -static apr_status_t read_headers(cache_handle_t *h, request_rec *r) +static apr_status_t recall_headers(cache_handle_t *h, request_rec *r) { int rc; mem_cache_object_t *mobj = (mem_cache_object_t*) h->cache_obj->vobj; @@ -700,7 +700,7 @@ static apr_status_t read_headers(cache_handle_t *h, request_rec *r) return rc; } -static apr_status_t read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb) +static apr_status_t recall_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb) { apr_bucket *b; mem_cache_object_t *mobj = (mem_cache_object_t*) h->cache_obj->vobj; @@ -723,7 +723,7 @@ static apr_status_t read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_briga } -static apr_status_t write_headers(cache_handle_t *h, request_rec *r, cache_info *info) +static apr_status_t store_headers(cache_handle_t *h, request_rec *r, cache_info *info) { cache_object_t *obj = h->cache_obj; mem_cache_object_t *mobj = (mem_cache_object_t*) obj->vobj; @@ -820,7 +820,7 @@ static apr_status_t write_headers(cache_handle_t *h, request_rec *r, cache_info return APR_SUCCESS; } -static apr_status_t write_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b) +static apr_status_t store_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b) { apr_status_t rv; cache_object_t *obj = h->cache_obj; -- 2.50.1