]> granicus.if.org Git - apache/commitdiff
"Thanks for checking in the changes to mod_mem_cache.
authorCliff Woolley <jwoolley@apache.org>
Wed, 10 Dec 2003 03:22:32 +0000 (03:22 +0000)
committerCliff Woolley <jwoolley@apache.org>
Wed, 10 Dec 2003 03:22:32 +0000 (03:22 +0000)
 I think there is a piece missing to that fixe;
 the adjustment of the queue_clock value in cache_cache.c
 (cache_insert()):
 Sorry about not finding/pointing that out before asking you to check in
 mod_mem_cache changes:

 queue_clock is initialized to 0 when initializing the cache.
 Based on the current conditional test (cache_cache.c, line 164):
 ----------------------------------------

        priority = c->get_pri(ejected);

        if (c->queue_clock < priority)
            c->queue_clock = priority;

 ----------------------------------------

 and the fact that the new get_pri() function return a negative value,
 queue_clock will NEVER be adjusted with the ejected element priority.
 This is a patch that should fix that problem:"

Submitted by: Jean-Jacques Clar
Generally glanced at by: Cliff Woolley (+1 on concept)
     (better to get it in there than to
      wait around for a year before I get
      a chance to really test it)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@102008 13f79535-47bb-0310-9956-ffa450edef68

modules/experimental/cache_cache.c
modules/experimental/mod_mem_cache.c

index 476980cc9a96d05ccc1bd59ff361220e1b5edc81..3b45bec8bf6bb733e48b5d755062def6f48f841c 100644 (file)
@@ -161,7 +161,7 @@ CACHE_DECLARE(void) cache_insert(cache_cache_t* c, void *entry)
         /* FIX: If ejected is NULL, we'll segfault here */
         priority = c->get_pri(ejected);
 
-        if (c->queue_clock < priority)
+        if (c->queue_clock > priority)
             c->queue_clock = priority;
 
         cache_hash_set(c->ht,
index d0a24ec0c3d4ee15eeadebcc49fea99cf9036fe0..8f93872252401aba45e01ae1001f05241abe24ea 100644 (file)
@@ -240,7 +240,7 @@ static long memcache_lru_algorithm(long queue_clock, void *a)
     cache_object_t *obj = (cache_object_t *)a;
     mem_cache_object_t *mobj = obj->vobj;
     if (mobj->priority == 0)
-        mobj->priority = -((long)(queue_clock + mobj->total_refs));
+        mobj->priority = queue_clock - mobj->total_refs;
 
     /* 
      * a 'proper' LRU function would just be
@@ -255,8 +255,8 @@ static long memcache_gdsf_algorithm(long queue_clock, void *a)
     mem_cache_object_t *mobj = obj->vobj;
 
     if (mobj->priority == 0)
-        mobj->priority = -(queue_clock +
-                           (long)(mobj->total_refs*1000 / mobj->m_len));
+        mobj->priority = queue_clock -
+                           (long)(mobj->total_refs*1000 / mobj->m_len);
 
     return mobj->priority;
 }