httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stodd...@apache.org
Subject cvs commit: httpd-2.0/modules/experimental mod_mem_cache.c
Date Wed, 17 Apr 2002 18:52:33 GMT
stoddard    02/04/17 11:52:33

  Modified:    .        CHANGES
               modules/experimental mod_mem_cache.c
  Log:
  Fix seg fault when garbage collecting an expired entry.  remove_entity
  should just remove the object from the cache and set the cleanup flag
  in the object. decrement_refcount will clean the object up when the refcount
  goes to zero.
  
  Defect reported by Jean-Jacques Clar at Novell.
  
  Revision  Changes    Path
  1.712     +2 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.711
  retrieving revision 1.712
  diff -u -r1.711 -r1.712
  --- CHANGES	17 Apr 2002 16:36:27 -0000	1.711
  +++ CHANGES	17 Apr 2002 18:52:32 -0000	1.712
  @@ -1,4 +1,6 @@
   Changes with Apache 2.0.36
  +  *) Fix segfault in mod_mem_cache when garabge collecting an expired
  +     cache entry.  [Bill Stoddard]
   
     *) Introduced -E startup_logfile_name option to httpd to allow admins
        to begin logging errors immediately.  This provides Win32 users 
  
  
  
  1.46      +7 -27     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.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- mod_mem_cache.c	5 Apr 2002 05:23:11 -0000	1.45
  +++ mod_mem_cache.c	17 Apr 2002 18:52:32 -0000	1.46
  @@ -477,10 +477,14 @@
   {
       cache_object_t *obj = h->cache_obj;
   
  -    /* Remove the cache object from the cache */
  +    /* Remove the cache object from the cache under protection */
       if (sconf->lock) {
           apr_thread_mutex_lock(sconf->lock);
       }
  +    /* Set the cleanup flag. Object will be cleaned up (be decrement_refcount)
  +     * when the refcount drops to zero.
  +     */
  +    obj->cleanup = 1;
       obj = (cache_object_t *) apr_hash_get(sconf->cacheht, obj->key,
                                             APR_HASH_KEY_STRING);
       if (obj) {
  @@ -489,35 +493,11 @@
           sconf->object_cnt--;
           sconf->cache_size -= mobj->m_len;
       }
  -    else {
  -        /* If the object was removed from the cache prior to this function being
  -         * called, then obj == NULL. Reinit obj with the object being cleaned up.
  -         * Note: This code assumes that there is at most only one object in the
  -         * cache per key.
  -         */
  -        obj = h->cache_obj;
  -    }
  -
  -    /* Cleanup the cache object 
  -     * Set obj->cleanup to ensure decrement_refcount cleans up the obj if it 
  -     * is still being referenced by another thread
  -     */
  -    obj->cleanup = 1;
  -#ifndef USE_ATOMICS
  -    obj->refcount--;
  -    if (!obj->refcount) {
  -        cleanup_cache_object(obj);
  -    }
  -#endif
       if (sconf->lock) {
           apr_thread_mutex_unlock(sconf->lock);
  -    }    
  -#ifdef USE_ATOMICS
  -    if (!apr_atomic_dec(&obj->refcount)) {
  -        cleanup_cache_object(obj);
       }
  -#endif
  -    h->cache_obj = NULL;   
  +
  +    h->cache_obj = NULL;
       return OK;
   }
   static apr_status_t serialize_table(cache_header_tbl_t **obj, 
  
  
  

Mime
View raw message