There is a memory leak with your patch when running my test. 
Using only the following part, it does not leak and works fine;
 
+                if (obj->cleanup) {
+                    /* If obj->cleanup is set, the object has been prematurly
+                     * ejected from the cache by the garbage collector. Add the
+                     * object back to the cache. If an object with the same key is
+                     * found in the cache, eject it in favor of the completed obj.
+                     */
+                    obj->cleanup = 0;
+                }
+                else {
+                    cache_remove(sconf->cache_cache, obj);
+                }

 
I need to do more investigation to find out which pieces of memory are
leaking. However, I am leaving for Xmas vacation, will be back only in 2004.
It is on my list of things to do when I come back.
 
Thank you for reviewing the submitted patch.
 
Jean-Jacques

>>> [EMAIL PROTECTED] 12/15/2003 5:36:39 PM >>>
I've not had time to test this but I believe it is a bit cleaner and altogether avoids the issue of duplicate
entries in the cache. What do you think?

Index: mod_mem_cache.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_mem_cache.c,v
retrieving revision 1.99
diff -u -r1.99 mod_mem_cache.c
--- mod_mem_cache.c    10 Dec 2003 03:22:32 -0000    1.99
+++ mod_mem_cache.c    16 Dec 2003 00:02:56 -0000
@@ -1043,7 +1043,25 @@
                  if (sconf->lock) {
                      apr_thread_mutex_lock(sconf->lock);
                  }
-                cache_remove(sconf->cache_cache, obj);
+                if (obj->cleanup) {
+                    /* If obj->cleanup is set, the object has been prematurly
+                     * ejected from the cache by the garbage collector. Add the
+                     * object back to the cache. If an object with the same key is
+                     * found in the cache, eject it in favor of the completed obj.
+                     */
+                    cache_object_t *tmp_obj =
+                      (cache_object_t *) cache_find(sconf->cache_cache, obj->key);
+                    if (tmp_obj) {
+                        cache_remove(sconf->cache_cache, tmp_obj);
+                        sconf->object_cnt--;
+                        sconf->cache_size -= mobj->m_len;
+                        tmp_obj->cleanup = 1;
+                    }
+                    obj->cleanup = 0;
+                }
+                else {
+                    cache_remove(sconf->cache_cache, obj);
+                }
                  mobj->m_len = obj->count;
                  cache_insert(sconf->cache_cache, obj);
                  sconf->cache_size -= (mobj->m_len - obj->count);


Reply via email to