"
APACHE_MODULE(cache, dynamic file caching, $cache_objs, , no)
APACHE_MODULE(disk_cache, disk caching module, , , no)
+APACHE_MODULE(mem_cache, memory caching module, , , no)
APACHE_MODULE(example, example and demo module, , , no)
APACHE_MODULE(ext_filter, external filter module, , , no)
APACHE_MODULE(case_filter, example uppercase conversion filter, , , no)
#define CORE_PRIVATE
#include "mod_cache.h"
+#include "ap_mpm.h"
#define MAX_CACHE 5000
module AP_MODULE_DECLARE_DATA mem_cache_module;
}
static void *create_cache_config(apr_pool_t *p, server_rec *s)
{
+ int threaded_mpm;
+
sconf = apr_pcalloc(p, sizeof(mem_cache_conf));
sconf->space = DEFAULT_CACHE_SPACE;
#if 0
sconf->defaultexpire = DEFAULT_CACHE_EXPIRE;
#endif
- apr_lock_create(&sconf->lock, APR_MUTEX, APR_INTRAPROCESS, "foo", p);
+ ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded_mpm);
+ if (threaded_mpm) {
+ apr_lock_create(&sconf->lock, APR_MUTEX, APR_INTRAPROCESS, "foo", p);
+ }
sconf->cacheht = apr_hash_make(p);
apr_pool_cleanup_register(p, NULL, cleanup_cache_mem, apr_pool_cleanup_null);
/* Mark the cache object as incomplete and put it into the cache */
obj->complete = 0;
- /* XXX Need a way to insert into the cache w/o sch coarse grained locking */
- apr_lock_acquire(sconf->lock);
+ /* XXX Need a way to insert into the cache w/o such coarse grained locking */
+ if (sconf->lock) {
+ apr_lock_acquire(sconf->lock);
+ }
apr_hash_set(sconf->cacheht, obj->key, strlen(obj->key), obj);
- apr_lock_release(sconf->lock);
+ if (sconf->lock) {
+ apr_lock_release(sconf->lock);
+ }
return OK;
}
if (strcasecmp(type, "mem")) {
return DECLINED;
}
- apr_lock_acquire(sconf->lock);
+ if (sconf->lock) {
+ apr_lock_acquire(sconf->lock);
+ }
obj = (cache_object_t *) apr_hash_get(sconf->cacheht, key, APR_HASH_KEY_STRING);
- apr_lock_release(sconf->lock);
+ if (sconf->lock) {
+ apr_lock_release(sconf->lock);
+ }
if (!obj || !(obj->complete)) {
return DECLINED;
{
cache_object_t *obj = (cache_object_t *) h->cache_obj;
- apr_lock_acquire(sconf->lock);
+ if (sconf->lock) {
+ apr_lock_acquire(sconf->lock);
+ }
apr_hash_set(sconf->cacheht, obj->key, strlen(obj->key), NULL);
- apr_lock_release(sconf->lock);
+ if (sconf->lock) {
+ apr_lock_release(sconf->lock);
+ }
cleanup_cache_object(obj);
/* The caller should free the cache_handle ? */
free(h);
+ return OK;
}
/* Define request processing hook handlers */
*/
/* First, find the object in the cache */
- apr_lock_acquire(sconf->lock);
+ if (sconf->lock) {
+ apr_lock_acquire(sconf->lock);
+ }
obj = (cache_object_t *) apr_hash_get(sconf->cacheht, key, APR_HASH_KEY_STRING);
- apr_lock_release(sconf->lock);
+ if (sconf->lock) {
+ apr_lock_release(sconf->lock);
+ }
if (!obj) {
return DECLINED;
}
/* Found it. Now take it out of the cache and free it. */
- apr_lock_acquire(sconf->lock);
+ if (sconf->lock) {
+ apr_lock_acquire(sconf->lock);
+ }
apr_hash_set(sconf->cacheht, obj->key, strlen(obj->key), NULL);
- apr_lock_release(sconf->lock);
+ if (sconf->lock) {
+ apr_lock_release(sconf->lock);
+ }
cleanup_cache_object(obj);
static int write_body(cache_handle *h, apr_bucket_brigade *b)
{
apr_status_t rv;
- apr_size_t idx = 0;
cache_object_t *obj = (cache_object_t *) h->cache_obj;
apr_read_type_e eblock = APR_BLOCK_READ;
apr_bucket *e;
}
static const char
-*set_cache_size(cmd_parms *parms, char *struct_ptr, char *arg)
+*set_cache_size(cmd_parms *parms, void *in_struct_ptr, const char *arg)
{
int val;