You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by st...@apache.org on 2002/03/12 03:54:25 UTC
cvs commit: httpd-2.0/modules/experimental mod_cache.h mod_mem_cache.c
stoddard 02/03/11 18:54:25
Modified: modules/experimental mod_cache.h mod_mem_cache.c
Log:
Move refcount and cleanup to the primary cache object (these fields can now
be used implementations other than mod_mem_cache)
Revision Changes Path
1.23 +2 -0 httpd-2.0/modules/experimental/mod_cache.h
Index: mod_cache.h
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_cache.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- mod_cache.h 9 Mar 2002 06:59:28 -0000 1.22
+++ mod_cache.h 12 Mar 2002 02:54:25 -0000 1.23
@@ -203,6 +203,8 @@
void *vobj; /* Opaque portion (specific to the cache implementation) of the cache object */
apr_size_t count; /* Number of body bytes written to the cache so far */
int complete;
+ apr_size_t refcount;
+ apr_size_t cleanup;
};
typedef struct cache_handle cache_handle_t;
1.31 +17 -18 httpd-2.0/modules/experimental/mod_mem_cache.c
Index: mod_mem_cache.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_mem_cache.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- mod_mem_cache.c 8 Mar 2002 21:59:25 -0000 1.30
+++ mod_mem_cache.c 12 Mar 2002 02:54:25 -0000 1.31
@@ -98,8 +98,6 @@
cache_header_tbl_t *header_out;
cache_header_tbl_t *subprocess_env;
cache_header_tbl_t *notes;
- apr_size_t cleanup;
- apr_size_t refcount;
apr_size_t m_len;
void *m;
apr_os_file_t fd;
@@ -201,11 +199,11 @@
if (sconf->lock) {
apr_thread_mutex_lock(sconf->lock);
}
- mobj->refcount--;
+ obj->refcount--;
/* If the object is marked for cleanup and the refcount
* has dropped to zero, cleanup the object
*/
- if ((mobj->cleanup) && (!mobj->refcount)) {
+ if ((obj->cleanup) && (!obj->refcount)) {
cleanup_cache_object(obj);
}
if (sconf->lock) {
@@ -232,8 +230,8 @@
apr_hash_this(hi, NULL, NULL, (void **)&obj);
if (obj) {
mobj = (mem_cache_object_t *) obj->vobj;
- if (mobj->refcount) {
- mobj->cleanup = 1;
+ if (obj->refcount) {
+ obj->cleanup = 1;
}
else {
cleanup_cache_object(obj);
@@ -358,8 +356,8 @@
* a partially completed (aborted) cache update.
*/
obj->complete = 0;
- mobj->refcount = 1;
- mobj->cleanup = 1;
+ obj->refcount = 1;
+ obj->cleanup = 1;
apr_pool_cleanup_register(r->pool, obj, decrement_refcount,
apr_pool_cleanup_null);
}
@@ -404,7 +402,7 @@
if (obj) {
mem_cache_object_t *mobj = (mem_cache_object_t *) obj->vobj;
if (obj->complete) {
- mobj->refcount++;
+ obj->refcount++;
apr_pool_cleanup_register(r->pool, obj, decrement_refcount, apr_pool_cleanup_null);
}
else {
@@ -445,8 +443,8 @@
apr_hash_set(sconf->cacheht, obj->key, strlen(obj->key), NULL);
sconf->object_cnt--;
sconf->cache_size -= mobj->m_len;
- if (mobj->refcount) {
- mobj->cleanup = 1;
+ if (obj->refcount) {
+ obj->cleanup = 1;
}
else {
cleanup_cache_object(obj);
@@ -542,8 +540,8 @@
apr_hash_set(sconf->cacheht, key, APR_HASH_KEY_STRING, NULL);
sconf->object_cnt--;
sconf->cache_size -= mobj->m_len;
- if (mobj->refcount) {
- mobj->cleanup = 1;
+ if (obj->refcount) {
+ obj->cleanup = 1;
}
else {
cleanup_cache_object(obj);
@@ -659,7 +657,8 @@
static apr_status_t write_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b)
{
apr_status_t rv;
- mem_cache_object_t *mobj = (mem_cache_object_t*) h->cache_obj->vobj;
+ cache_object_t *obj = h->cache_obj;
+ mem_cache_object_t *mobj = (mem_cache_object_t*) obj->vobj;
apr_read_type_e eblock = APR_BLOCK_READ;
apr_bucket *e;
char *cur;
@@ -701,8 +700,8 @@
apr_file_unset_inherit(tmpfile);
apr_os_file_get(&(mobj->fd), tmpfile);
- mobj->cleanup = 0;
- mobj->refcount--; /* Count should be 0 now */
+ obj->cleanup = 0;
+ obj->refcount--; /* Count should be 0 now */
apr_pool_cleanup_kill(r->pool, h->cache_obj, decrement_refcount);
/* Open for business */
@@ -731,8 +730,8 @@
apr_size_t len;
if (APR_BUCKET_IS_EOS(e)) {
- mobj->cleanup = 0;
- mobj->refcount--; /* Count should be 0 now */
+ obj->cleanup = 0;
+ obj->refcount--; /* Count should be 0 now */
apr_pool_cleanup_kill(r->pool, h->cache_obj, decrement_refcount);
/* Open for business */