httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwool...@apache.org
Subject cvs commit: httpd-2.0/modules/experimental mod_mem_cache.c
Date Tue, 02 Dec 2003 19:07:42 GMT
jwoolley    2003/12/02 11:07:42

  Modified:    modules/experimental mod_mem_cache.c
  Log:
  Fixed mod_mem_cache so that it doesn't misfile entries in the priority
  queue.  Previously, since the ->priority value was positive, certain
  parts of mod_mem_cache would cause the priority queue to do the wrong thing
  when changing the priority of an object in the cache.  The end result
  would be that the objects would not be dequeued in the right order.
  
  Submitted by:  Jean-Jacques Clar, Cliff Woolley
  Reviewed by:   Paul J. Reder
  
  Revision  Changes    Path
  1.97      +7 -5      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.96
  retrieving revision 1.97
  diff -u -d -u -r1.96 -r1.97
  --- mod_mem_cache.c	16 Nov 2003 02:09:13 -0000	1.96
  +++ mod_mem_cache.c	2 Dec 2003 19:07:41 -0000	1.97
  @@ -232,20 +232,21 @@
   #endif
   }
   /*
  - * functions return a 'negative' score as lower is better in a priority Q
  + * functions return a 'negative' score since priority queues
  + * dequeue the object with the highest value first
    */
   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 = -((long)(queue_clock + mobj->total_refs));
   
       /*	
        * a 'proper' LRU function would just be
        *  mobj->priority = mobj->total_refs; 
        */
  -    return -1*mobj->priority;
  +    return mobj->priority;
   }
   
   static long memcache_gdsf_algorithm(long queue_clock, void *a) 
  @@ -254,9 +255,10 @@
       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 -1*mobj->priority;
  +    return mobj->priority;
   }
   
   static void cleanup_cache_object(cache_object_t *obj)
  
  
  

Mime
View raw message