httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject cvs commit: httpd-2.0/modules/experimental mod_cache.h mod_mem_cache.c
Date Mon, 02 Aug 2004 17:18:15 GMT
jerenkrantz    2004/08/02 10:18:15

  Modified:    modules/experimental mod_cache.h mod_mem_cache.c
  Log:
  * modules/experimental/mod_cache.h: Always use atomics.
  * modules/experimental/mod_mem_cache.c: Always use atomics.
  
  Reviewed by:	Bill Stoddard
  
  Revision  Changes    Path
  1.45      +0 -8      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.44
  retrieving revision 1.45
  diff -u -u -r1.44 -r1.45
  --- mod_cache.h	9 Feb 2004 20:29:18 -0000	1.44
  +++ mod_cache.h	2 Aug 2004 17:18:15 -0000	1.45
  @@ -64,11 +64,7 @@
   #include <arpa/inet.h>
   #endif
   
  -/* USE_ATOMICS should be replaced with the appropriate APR feature macro */
  -#define USE_ATOMICS
  -#ifdef USE_ATOMICS
   #include "apr_atomic.h"
  -#endif
   
   #ifndef MAX
   #define MAX(a,b)                ((a) > (b) ? (a) : (b))
  @@ -175,11 +171,7 @@
       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;
  -#ifdef USE_ATOMICS
       apr_uint32_t refcount;
  -#else
  -    apr_size_t refcount;
  -#endif
       apr_size_t cleanup;
   };
   
  
  
  
  1.110     +0 -61     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.109
  retrieving revision 1.110
  diff -u -u -r1.109 -r1.110
  --- mod_mem_cache.c	25 May 2004 18:22:58 -0000	1.109
  +++ mod_mem_cache.c	2 Aug 2004 17:18:15 -0000	1.110
  @@ -59,11 +59,7 @@
       long priority;      /**< the priority of this entry */
       long total_refs;          /**< total number of references this entry has had */
   
  -#ifdef USE_ATOMICS
       apr_uint32_t pos;   /**< the position of this entry in the cache */
  -#else
  -    apr_ssize_t pos;
  -#endif
   
   } mem_cache_object_t;
   
  @@ -122,22 +118,14 @@
       cache_object_t *obj = (cache_object_t *)a;
       mem_cache_object_t *mobj = obj->vobj;
   
  -#ifdef USE_ATOMICS
       apr_atomic_set32(&mobj->pos, pos);
  -#else
  -    mobj->pos = pos;
  -#endif    
   }
   static apr_ssize_t memcache_get_pos(void *a)
   {
       cache_object_t *obj = (cache_object_t *)a;
       mem_cache_object_t *mobj = obj->vobj;
   
  -#ifdef USE_ATOMICS
       return apr_atomic_read32(&mobj->pos);
  -#else
  -    return mobj->pos;
  -#endif    
   }
   
   static apr_size_t memcache_cache_get_size(void*a)
  @@ -167,24 +155,13 @@
        * now. Increment the refcount before setting cleanup to avoid a race 
        * condition. A similar pattern is used in remove_url()
        */
  -#ifdef USE_ATOMICS
       apr_atomic_inc32(&obj->refcount);
  -#else
  -    obj->refcount++;
  -#endif
   
       obj->cleanup = 1;
   
  -#ifdef USE_ATOMICS
       if (!apr_atomic_dec32(&obj->refcount)) {
           cleanup_cache_object(obj);
       }
  -#else
  -    obj->refcount--;
  -    if (!obj->refcount) {
  -        cleanup_cache_object(obj);
  -    }
  -#endif
   }
   /*
    * functions return a 'negative' score since priority queues
  @@ -310,27 +287,11 @@
       }
   
       /* Cleanup the cache object */
  -#ifdef USE_ATOMICS
       if (!apr_atomic_dec32(&obj->refcount)) {
           if (obj->cleanup) {
               cleanup_cache_object(obj);
           }
       }
  -#else
  -    if (sconf->lock) {
  -        apr_thread_mutex_lock(sconf->lock);
  -    }
  -    obj->refcount--;
  -    /* If the object is marked for cleanup and the refcount
  -     * has dropped to zero, cleanup the object
  -     */
  -    if ((obj->cleanup) && (!obj->refcount)) {
  -        cleanup_cache_object(obj);
  -    }
  -    if (sconf->lock) {
  -        apr_thread_mutex_unlock(sconf->lock);
  -    }
  -#endif
       return APR_SUCCESS;
   }
   static apr_status_t cleanup_cache_mem(void *sconfv)
  @@ -352,14 +313,9 @@
       while (obj) {         
       /* Iterate over the cache and clean up each entry */  
       /* Free the object if the recount == 0 */
  -#ifdef USE_ATOMICS
           apr_atomic_inc32(&obj->refcount);
           obj->cleanup = 1;
           if (!apr_atomic_dec32(&obj->refcount)) {
  -#else
  -        obj->cleanup = 1;
  -        if (!obj->refcount) {
  -#endif
               cleanup_cache_object(obj);
           }
           obj = cache_pop(co->cache_cache);
  @@ -468,11 +424,7 @@
       }
   
       /* Finish initing the cache object */
  -#ifdef USE_ATOMICS
       apr_atomic_set32(&obj->refcount, 1);
  -#else 
  -    obj->refcount = 1;
  -#endif
       mobj->total_refs = 1;
       obj->complete = 0;
       obj->cleanup = 0;
  @@ -543,11 +495,7 @@
       if (obj) {
           if (obj->complete) {
               request_rec *rmain=r, *rtmp;
  -#ifdef USE_ATOMICS
               apr_atomic_inc32(&obj->refcount);
  -#else
  -            obj->refcount++;
  -#endif
               /* cache is worried about overall counts, not 'open' ones */
               cache_update(sconf->cache_cache, obj);
   
  @@ -698,17 +646,10 @@
           cache_remove(sconf->cache_cache, obj);
           mobj = (mem_cache_object_t *) obj->vobj;
   
  -#ifdef USE_ATOMICS
           /* Refcount increment in this case MUST be made under 
            * protection of the lock 
            */
           apr_atomic_inc32(&obj->refcount);
  -#else
  -        if (!obj->refcount) {
  -            cleanup_cache_object(obj);
  -            obj = NULL;
  -        }
  -#endif
           if (obj) {
               obj->cleanup = 1;
           }
  @@ -716,13 +657,11 @@
       if (sconf->lock) {
           apr_thread_mutex_unlock(sconf->lock);
       }
  -#ifdef USE_ATOMICS
       if (obj) {
           if (!apr_atomic_dec32(&obj->refcount)) {
               cleanup_cache_object(obj);
           }
       }
  -#endif
       return OK;
   }
   
  
  
  

Mime
View raw message