Clean up code style in the cache code and shrink the mod_mem_cache store_body function.
Index: modules/cache/mod_mem_cache.c =================================================================== --- modules/cache/mod_mem_cache.c.orig +++ modules/cache/mod_mem_cache.c @@ -52,27 +52,30 @@ module AP_MODULE_DECLARE_DATA mem_cache_module; -typedef enum { +typedef enum +{ CACHE_TYPE_FILE = 1, CACHE_TYPE_HEAP, CACHE_TYPE_MMAP } cache_type_e; -typedef struct { - char* hdr; - char* val; +typedef struct +{ + char *hdr; + char *val; } cache_header_tbl_t; -typedef struct mem_cache_object { +typedef struct mem_cache_object +{ cache_type_e type; apr_ssize_t num_header_out; apr_ssize_t num_req_hdrs; cache_header_tbl_t *header_out; - cache_header_tbl_t *req_hdrs; /* for Vary negotiation */ + cache_header_tbl_t *req_hdrs; /* for Vary negotiation */ apr_size_t m_len; void *m; apr_os_file_t fd; - apr_int32_t flags; /* File open flags */ + apr_int32_t flags; /* File open flags */ long priority; /**< the priority of this entry */ long total_refs; /**< total number of references this entry has had */ @@ -80,14 +83,15 @@ } mem_cache_object_t; -typedef struct { +typedef struct +{ apr_thread_mutex_t *lock; cache_cache_t *cache_cache; /* Fields set by config directives */ apr_size_t min_cache_object_size; /* in bytes */ apr_size_t max_cache_object_size; /* in bytes */ - apr_size_t max_cache_size; /* in bytes */ + apr_size_t max_cache_size; /* in bytes */ apr_size_t max_object_cnt; cache_pqueue_set_priority cache_remove_algorithm; @@ -95,8 +99,11 @@ * we haven't yet seen EOS */ apr_off_t max_streaming_buffer_size; } mem_cache_conf; + static mem_cache_conf *sconf; +static void cleanup_cache_object(cache_object_t * obj); + #define DEFAULT_MAX_CACHE_SIZE 100*1024 #define DEFAULT_MIN_CACHE_OBJECT_SIZE 0 #define DEFAULT_MAX_CACHE_OBJECT_SIZE 10000 @@ -104,15 +111,6 @@ #define DEFAULT_MAX_STREAMING_BUFFER_SIZE 100000 #define CACHEFILE_LEN 20 -/* Forward declarations */ -static int remove_entity(cache_handle_t *h); -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); - static long memcache_get_priority(void*a) { cache_object_t *obj = (cache_object_t *)a; @@ -132,31 +130,34 @@ static void memcache_set_pos(void *a, apr_ssize_t pos) { - cache_object_t *obj = (cache_object_t *)a; + cache_object_t *obj = (cache_object_t *) a; mem_cache_object_t *mobj = obj->vobj; apr_atomic_set32(&mobj->pos, pos); } + static apr_ssize_t memcache_get_pos(void *a) { - cache_object_t *obj = (cache_object_t *)a; + cache_object_t *obj = (cache_object_t *) a; mem_cache_object_t *mobj = obj->vobj; return apr_atomic_read32(&mobj->pos); } -static apr_size_t memcache_cache_get_size(void*a) +static apr_size_t memcache_cache_get_size(void *a) { - cache_object_t *obj = (cache_object_t *)a; + cache_object_t *obj = (cache_object_t *) a; mem_cache_object_t *mobj = obj->vobj; return mobj->m_len; } + /** callback to get the key of a item */ -static const char* memcache_cache_get_key(void*a) +static const char *memcache_cache_get_key(void *a) { - cache_object_t *obj = (cache_object_t *)a; + cache_object_t *obj = (cache_object_t *) a; return obj->key; } + /** * memcache_cache_free() * memcache_cache_free is a callback that is only invoked by a thread @@ -165,9 +166,9 @@ * has been ejected from the cache. decrement the refcount and if the refcount drops * to 0, cleanup the cache object. */ -static void memcache_cache_free(void*a) +static void memcache_cache_free(void *a) { - cache_object_t *obj = (cache_object_t *)a; + cache_object_t *obj = (cache_object_t *) a; /* Decrement the refcount to account for the object being ejected * from the cache. If the refcount is 0, free the object. @@ -176,13 +177,14 @@ cleanup_cache_object(obj); } } + /* * functions return a 'negative' score since priority queues * dequeue the object with the highest value first */ static long memcache_lru_algorithm(long queue_clock, void *a) { - cache_object_t *obj = (cache_object_t *)a; + cache_object_t *obj = (cache_object_t *) a; mem_cache_object_t *mobj = obj->vobj; if (mobj->priority == 0) mobj->priority = queue_clock - mobj->total_refs; @@ -196,17 +198,17 @@ static long memcache_gdsf_algorithm(long queue_clock, void *a) { - cache_object_t *obj = (cache_object_t *)a; + cache_object_t *obj = (cache_object_t *) a; mem_cache_object_t *mobj = obj->vobj; if (mobj->priority == 0) mobj->priority = queue_clock - - (long)(mobj->total_refs*1000 / mobj->m_len); + (long) (mobj->total_refs * 1000 / mobj->m_len); return mobj->priority; } -static void cleanup_cache_object(cache_object_t *obj) +static void cleanup_cache_object(cache_object_t * obj) { mem_cache_object_t *mobj = obj->vobj; @@ -218,7 +220,7 @@ /* Cleanup the cache_object_t */ if (obj->key) { - free((void*)obj->key); + free((void *) obj->key); } free(obj); @@ -248,6 +250,7 @@ free(mobj); } } + static apr_status_t decrement_refcount(void *arg) { cache_object_t *obj = (cache_object_t *) arg; @@ -279,10 +282,11 @@ } return APR_SUCCESS; } + static apr_status_t cleanup_cache_mem(void *sconfv) { cache_object_t *obj; - mem_cache_conf *co = (mem_cache_conf*) sconfv; + mem_cache_conf *co = (mem_cache_conf *) sconfv; if (!co) { return APR_SUCCESS; @@ -311,10 +315,11 @@ } return APR_SUCCESS; } + /* * TODO: enable directives to be overridden in various containers */ -static void *create_cache_config(apr_pool_t *p, server_rec *s) +static void *create_cache_config(apr_pool_t * p, server_rec *s) { sconf = apr_pcalloc(p, sizeof(mem_cache_conf)); @@ -331,7 +336,7 @@ return sconf; } -static int create_entity(cache_handle_t *h, cache_type_e type_e, +static int create_entity(cache_handle_t * h, cache_type_e type_e, request_rec *r, const char *key, apr_off_t len) { cache_object_t *obj, *tmp_obj; @@ -381,7 +386,7 @@ cleanup_cache_object(obj); return DECLINED; } - memcpy((void*)obj->key, key, key_len); + memcpy((void *) obj->key, key, key_len); /* Allocate and init mem_cache_object_t */ mobj = calloc(1, sizeof(*mobj)); @@ -396,7 +401,7 @@ obj->complete = 0; obj->vobj = mobj; /* Safe cast: We tested < sconf->max_cache_object_size above */ - mobj->m_len = (apr_size_t)len; + mobj->m_len = (apr_size_t) len; mobj->type = type_e; /* Place the cache_object_t into the hash table. @@ -446,19 +451,19 @@ return OK; } -static int create_mem_entity(cache_handle_t *h, request_rec *r, +static int create_mem_entity(cache_handle_t * h, request_rec *r, const char *key, apr_off_t len) { return create_entity(h, CACHE_TYPE_HEAP, r, key, len); } -static int create_fd_entity(cache_handle_t *h, request_rec *r, +static int create_fd_entity(cache_handle_t * h, request_rec *r, const char *key, apr_off_t len) { return create_entity(h, CACHE_TYPE_FILE, r, key, len); } -static int open_entity(cache_handle_t *h, request_rec *r, const char *key) +static int open_entity(cache_handle_t * h, request_rec *r, const char *key) { cache_object_t *obj; @@ -469,7 +474,7 @@ obj = (cache_object_t *) cache_find(sconf->cache_cache, key); if (obj) { if (obj->complete) { - request_rec *rmain=r, *rtmp; + request_rec *rmain = r, *rtmp; apr_atomic_inc32(&obj->refcount); /* cache is worried about overall counts, not 'open' ones */ cache_update(sconf->cache_cache, obj); @@ -502,7 +507,7 @@ /* Initialize the cache_handle */ h->cache_obj = obj; - h->req_hdrs = NULL; /* Pick these up in recall_headers() */ + h->req_hdrs = NULL; /* Pick these up in recall_headers() */ return OK; } @@ -513,7 +518,7 @@ * object has been removed from the cache by another thread and this thread * is the last thread accessing the object. */ -static int remove_entity(cache_handle_t *h) +static int remove_entity(cache_handle_t * h) { cache_object_t *obj = h->cache_obj; cache_object_t *tobj = NULL; @@ -539,9 +544,9 @@ return OK; } -static apr_status_t serialize_table(cache_header_tbl_t **obj, - apr_ssize_t *nelts, - apr_table_t *table) + +static apr_status_t serialize_table(cache_header_tbl_t ** obj, + apr_ssize_t * nelts, apr_table_t * table) { const apr_array_header_t *elts_arr = apr_table_elts(table); apr_table_entry_t *elts = (apr_table_entry_t *) elts_arr->elts; @@ -551,8 +556,8 @@ char *buf; *nelts = elts_arr->nelts; - if (*nelts == 0 ) { - *obj=NULL; + if (*nelts == 0) { + *obj = NULL; return APR_SUCCESS; } *obj = malloc(sizeof(cache_header_tbl_t) * elts_arr->nelts); @@ -562,7 +567,7 @@ for (i = 0; i < elts_arr->nelts; ++i) { len += strlen(elts[i].key); len += strlen(elts[i].val); - len += 2; /* Extra space for NULL string terminator for key and val */ + len += 2; /* Extra space for NULL string terminator for key and val */ } /* Transfer the headers into a contiguous memory block */ @@ -575,20 +580,20 @@ for (i = 0; i < *nelts; ++i) { (*obj)[i].hdr = &buf[idx]; - len = strlen(elts[i].key) + 1; /* Include NULL terminator */ + len = strlen(elts[i].key) + 1; /* Include NULL terminator */ memcpy(&buf[idx], elts[i].key, len); - idx+=len; + idx += len; (*obj)[i].val = &buf[idx]; len = strlen(elts[i].val) + 1; memcpy(&buf[idx], elts[i].val, len); - idx+=len; + idx += len; } return APR_SUCCESS; } -static int unserialize_table( cache_header_tbl_t *ctbl, - int num_headers, - apr_table_t *t ) + +static int unserialize_table(cache_header_tbl_t * ctbl, int num_headers, + apr_table_t * t) { int i; @@ -598,11 +603,9 @@ return APR_SUCCESS; } + /* Define request processing hook handlers */ -/* remove_url() - * Notes: - */ -static int remove_url(cache_handle_t *h, apr_pool_t *p) +static int remove_url(cache_handle_t * h, apr_pool_t * p) { cache_object_t *obj; int cleanup = 0; @@ -643,10 +646,11 @@ return rc; } -static apr_status_t recall_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; + mem_cache_object_t *mobj = (mem_cache_object_t *) h->cache_obj->vobj; if (mobj->type == CACHE_TYPE_FILE) { /* CACHE_TYPE_FILE */ @@ -657,7 +661,8 @@ } else { /* CACHE_TYPE_HEAP */ - b = apr_bucket_immortal_create(mobj->m, mobj->m_len, bb->bucket_alloc); + b = apr_bucket_immortal_create(mobj->m, mobj->m_len, + bb->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, b); } b = apr_bucket_eos_create(bb->bucket_alloc); @@ -667,10 +672,11 @@ } -static apr_status_t store_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; + mem_cache_object_t *mobj = (mem_cache_object_t *) obj->vobj; int rc; apr_table_t *headers_out; @@ -681,9 +687,7 @@ * - The original response headers (for returning with a cached response) * - The body of the message */ - rc = serialize_table(&mobj->req_hdrs, - &mobj->num_req_hdrs, - r->headers_in); + rc = serialize_table(&mobj->req_hdrs, &mobj->num_req_hdrs, r->headers_in); if (rc != APR_SUCCESS) { return rc; } @@ -725,12 +729,66 @@ return APR_SUCCESS; } -static apr_status_t store_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b) +static void update_object_on_cache(cache_object_t * obj, + mem_cache_object_t * mobj) +{ + cache_object_t *tobj = NULL; + + /* Now comes the crufty part... there is no way to tell the + * cache that the size of the object has changed. We need + * to remove the object, update the size and re-add the + * object, all under protection of the lock. + */ + if (sconf->lock) { + apr_thread_mutex_lock(sconf->lock); + } + + /* Has the object been ejected from the cache? */ + tobj = (cache_object_t *) cache_find(sconf->cache_cache, obj->key); + + if (tobj == obj) { + /* Object is still in the cache, remove it, update the len field then + * replace it under protection of sconf->lock. + */ + cache_remove(sconf->cache_cache, obj); + + /* For illustration, cache no longer has reference to the object + * so decrement the refcount + * apr_atomic_dec32(&obj->refcount); + */ + mobj->m_len = obj->count; + + cache_insert(sconf->cache_cache, obj); + /* For illustration, cache now has reference to the object, so + * increment the refcount + * apr_atomic_inc32(&obj->refcount); + */ + } + else if (tobj) { + /* Different object with the same key found in the cache. Doing nothing + * here will cause the object refcount to drop to 0 in decrement_refcount + * and the object will be cleaned up. + */ + + } + else { + /* Object has been ejected from the cache, add it back to the cache */ + mobj->m_len = obj->count; + cache_insert(sconf->cache_cache, obj); + apr_atomic_inc32(&obj->refcount); + } + + if (sconf->lock) { + apr_thread_mutex_unlock(sconf->lock); + } +} + +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; - cache_object_t *tobj = NULL; - mem_cache_object_t *mobj = (mem_cache_object_t*) obj->vobj; + mem_cache_object_t *mobj = (mem_cache_object_t *) obj->vobj; apr_read_type_e eblock = APR_BLOCK_READ; apr_bucket *e; char *cur; @@ -747,9 +805,7 @@ * - the file_bucket is the last data bucket in the brigade */ for (e = APR_BRIGADE_FIRST(b); - e != APR_BRIGADE_SENTINEL(b); - e = APR_BUCKET_NEXT(e)) - { + e != APR_BRIGADE_SENTINEL(b); e = APR_BUCKET_NEXT(e)) { if (APR_BUCKET_IS_EOS(e)) { eos = 1; } @@ -768,9 +824,10 @@ /* Open a new XTHREAD handle to the file */ apr_file_name_get(&name, file); mobj->flags = ((APR_SENDFILE_ENABLED & apr_file_flags_get(file)) - | APR_READ | APR_BINARY | APR_XTHREAD | APR_FILE_NOCLEANUP); - rv = apr_file_open(&tmpfile, name, mobj->flags, - APR_OS_DEFAULT, r->pool); + | APR_READ | APR_BINARY | APR_XTHREAD | + APR_FILE_NOCLEANUP); + rv = apr_file_open(&tmpfile, name, mobj->flags, APR_OS_DEFAULT, + r->pool); if (rv != APR_SUCCESS) { return rv; } @@ -779,7 +836,8 @@ /* Open for business */ ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server, - "mem_cache: Cached file: %s with key: %s", name, obj->key); + "mem_cache: Cached file: %s with key: %s", name, + obj->key); obj->complete = 1; return APR_SUCCESS; } @@ -799,13 +857,11 @@ } obj->count = 0; } - cur = (char*) mobj->m + obj->count; + cur = (char *) mobj->m + obj->count; /* Iterate accross the brigade and populate the cache storage */ for (e = APR_BRIGADE_FIRST(b); - e != APR_BRIGADE_SENTINEL(b); - e = APR_BUCKET_NEXT(e)) - { + e != APR_BRIGADE_SENTINEL(b); e = APR_BUCKET_NEXT(e)) { const char *s; apr_size_t len; @@ -815,57 +871,16 @@ * correct size and copy the streamed response into that * buffer */ char *buf = malloc(obj->count); + if (!buf) { return APR_ENOMEM; } + memcpy(buf, mobj->m, obj->count); free(mobj->m); mobj->m = buf; - /* Now comes the crufty part... there is no way to tell the - * cache that the size of the object has changed. We need - * to remove the object, update the size and re-add the - * object, all under protection of the lock. - */ - if (sconf->lock) { - apr_thread_mutex_lock(sconf->lock); - } - /* Has the object been ejected from the cache? - */ - tobj = (cache_object_t *) cache_find(sconf->cache_cache, obj->key); - if (tobj == obj) { - /* Object is still in the cache, remove it, update the len field then - * replace it under protection of sconf->lock. - */ - cache_remove(sconf->cache_cache, obj); - /* For illustration, cache no longer has reference to the object - * so decrement the refcount - * apr_atomic_dec32(&obj->refcount); - */ - mobj->m_len = obj->count; - - cache_insert(sconf->cache_cache, obj); - /* For illustration, cache now has reference to the object, so - * increment the refcount - * apr_atomic_inc32(&obj->refcount); - */ - } - else if (tobj) { - /* Different object with the same key found in the cache. Doing nothing - * here will cause the object refcount to drop to 0 in decrement_refcount - * and the object will be cleaned up. - */ - - } else { - /* Object has been ejected from the cache, add it back to the cache */ - mobj->m_len = obj->count; - cache_insert(sconf->cache_cache, obj); - apr_atomic_inc32(&obj->refcount); - } - - if (sconf->lock) { - apr_thread_mutex_unlock(sconf->lock); - } + update_object_on_cache(obj, mobj); } /* Open for business */ ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server, @@ -879,14 +894,14 @@ } if (len) { /* Check for buffer overflow */ - if ((obj->count + len) > mobj->m_len) { - return APR_ENOMEM; - } - else { - memcpy(cur, s, len); - cur+=len; - obj->count+=len; - } + if ((obj->count + len) > mobj->m_len) { + return APR_ENOMEM; + } + else { + memcpy(cur, s, len); + cur += len; + obj->count += len; + } } /* This should not fail, but if it does, we are in BIG trouble * cause we just stomped all over the heap. @@ -895,11 +910,12 @@ } return APR_SUCCESS; } + /** * Configuration and start-up */ -static int mem_cache_post_config(apr_pool_t *p, apr_pool_t *plog, - apr_pool_t *ptemp, server_rec *s) +static int mem_cache_post_config(apr_pool_t * p, apr_pool_t * plog, + apr_pool_t * ptemp, server_rec *s) { int threaded_mpm; @@ -917,8 +933,10 @@ if (sconf->max_streaming_buffer_size > sconf->max_cache_object_size) { /* Issue a notice only if something other than the default config * is being used */ - if (sconf->max_streaming_buffer_size != DEFAULT_MAX_STREAMING_BUFFER_SIZE && - sconf->max_cache_object_size != DEFAULT_MAX_CACHE_OBJECT_SIZE) { + if (sconf->max_streaming_buffer_size != + DEFAULT_MAX_STREAMING_BUFFER_SIZE + && sconf->max_cache_object_size != + DEFAULT_MAX_CACHE_OBJECT_SIZE) { ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s, "MCacheMaxStreamingBuffer must be less than or equal to MCacheMaxObjectSize. " "Resetting MCacheMaxStreamingBuffer to MCacheMaxObjectSize."); @@ -946,7 +964,8 @@ memcache_cache_get_size, memcache_cache_get_key, memcache_cache_free); - apr_pool_cleanup_register(p, sconf, cleanup_cache_mem, apr_pool_cleanup_null); + apr_pool_cleanup_register(p, sconf, cleanup_cache_mem, + apr_pool_cleanup_null); if (sconf->cache_cache) return OK; @@ -955,19 +974,22 @@ } -static const char -*set_max_cache_size(cmd_parms *parms, void *in_struct_ptr, const char *arg) +static const char *set_max_cache_size(cmd_parms *parms, void *in_struct_ptr, + const char *arg) { apr_size_t val; if (sscanf(arg, "%" APR_SIZE_T_FMT, &val) != 1) { - return "MCacheSize argument must be an integer representing the max cache size in KBytes."; + return + "MCacheSize argument must be an integer representing the max cache size in KBytes."; } - sconf->max_cache_size = val*1024; + sconf->max_cache_size = val * 1024; return NULL; } -static const char -*set_min_cache_object_size(cmd_parms *parms, void *in_struct_ptr, const char *arg) + +static const char *set_min_cache_object_size(cmd_parms *parms, + void *in_struct_ptr, + const char *arg) { apr_size_t val; @@ -977,8 +999,10 @@ sconf->min_cache_object_size = val; return NULL; } -static const char -*set_max_cache_object_size(cmd_parms *parms, void *in_struct_ptr, const char *arg) + +static const char *set_max_cache_object_size(cmd_parms *parms, + void *in_struct_ptr, + const char *arg) { apr_size_t val; @@ -988,8 +1012,9 @@ sconf->max_cache_object_size = val; return NULL; } -static const char -*set_max_object_count(cmd_parms *parms, void *in_struct_ptr, const char *arg) + +static const char *set_max_object_count(cmd_parms *parms, void *in_struct_ptr, + const char *arg) { apr_size_t val; @@ -1000,8 +1025,8 @@ return NULL; } -static const char -*set_cache_removal_algorithm(cmd_parms *parms, void *name, const char *arg) +static const char *set_cache_removal_algorithm(cmd_parms *parms, void *name, + const char *arg) { if (strcasecmp("LRU", arg)) { sconf->cache_remove_algorithm = memcache_lru_algorithm; @@ -1028,25 +1053,23 @@ return NULL; } -static const command_rec cache_cmds[] = -{ +static const command_rec cache_cmds[] = { AP_INIT_TAKE1("MCacheSize", set_max_cache_size, NULL, RSRC_CONF, - "The maximum amount of memory used by the cache in KBytes"), + "The maximum amount of memory used by the cache in KBytes"), AP_INIT_TAKE1("MCacheMaxObjectCount", set_max_object_count, NULL, RSRC_CONF, - "The maximum number of objects allowed to be placed in the cache"), + "The maximum number of objects allowed to be placed in the cache"), AP_INIT_TAKE1("MCacheMinObjectSize", set_min_cache_object_size, NULL, RSRC_CONF, - "The minimum size (in bytes) of an object to be placed in the cache"), + "The minimum size (in bytes) of an object to be placed in the cache"), AP_INIT_TAKE1("MCacheMaxObjectSize", set_max_cache_object_size, NULL, RSRC_CONF, - "The maximum size (in bytes) of an object to be placed in the cache"), + "The maximum size (in bytes) of an object to be placed in the cache"), AP_INIT_TAKE1("MCacheRemovalAlgorithm", set_cache_removal_algorithm, NULL, RSRC_CONF, - "The algorithm used to remove entries from the cache (default: GDSF)"), + "The algorithm used to remove entries from the cache (default: GDSF)"), AP_INIT_TAKE1("MCacheMaxStreamingBuffer", set_max_streaming_buffer, NULL, RSRC_CONF, - "Maximum number of bytes of content to buffer for a streamed response"), + "Maximum number of bytes of content to buffer for a streamed response"), {NULL} }; -static const cache_provider cache_mem_provider = -{ +static const cache_provider cache_mem_provider = { &remove_entity, &store_headers, &store_body, @@ -1057,8 +1080,7 @@ &remove_url, }; -static const cache_provider cache_fd_provider = -{ +static const cache_provider cache_fd_provider = { &remove_entity, &store_headers, &store_body, @@ -1069,29 +1091,21 @@ &remove_url, }; -static void register_hooks(apr_pool_t *p) +static void register_hooks(apr_pool_t * p) { ap_hook_post_config(mem_cache_post_config, NULL, NULL, APR_HOOK_MIDDLE); - /* cache initializer */ - /* cache_hook_init(cache_mem_init, NULL, NULL, APR_HOOK_MIDDLE); */ - /* - cache_hook_create_entity(create_entity, NULL, NULL, APR_HOOK_MIDDLE); - cache_hook_open_entity(open_entity, NULL, NULL, APR_HOOK_MIDDLE); - cache_hook_remove_url(remove_url, NULL, NULL, APR_HOOK_MIDDLE); - */ ap_register_provider(p, CACHE_PROVIDER_GROUP, "mem", "0", &cache_mem_provider); ap_register_provider(p, CACHE_PROVIDER_GROUP, "fd", "0", &cache_fd_provider); } -module AP_MODULE_DECLARE_DATA mem_cache_module = -{ +module AP_MODULE_DECLARE_DATA mem_cache_module = { STANDARD20_MODULE_STUFF, - NULL, /* create per-directory config structure */ - NULL, /* merge per-directory config structures */ - create_cache_config, /* create per-server config structure */ - NULL, /* merge per-server config structures */ - cache_cmds, /* command apr_table_t */ + NULL, /* create per-directory config structure */ + NULL, /* merge per-directory config structures */ + create_cache_config, /* create per-server config structure */ + NULL, /* merge per-server config structures */ + cache_cmds, /* command apr_table_t */ register_hooks }; --