Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 27874 invoked from network); 2 Dec 2003 19:08:15 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 2 Dec 2003 19:08:15 -0000 Received: (qmail 34238 invoked by uid 500); 2 Dec 2003 19:07:44 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 34068 invoked by uid 500); 2 Dec 2003 19:07:42 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 33907 invoked by uid 500); 2 Dec 2003 19:07:40 -0000 Delivered-To: apmail-httpd-2.0-cvs@apache.org Received: (qmail 33598 invoked from network); 2 Dec 2003 19:07:33 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 2 Dec 2003 19:07:33 -0000 Received: (qmail 26572 invoked by uid 1259); 2 Dec 2003 19:07:42 -0000 Date: 2 Dec 2003 19:07:42 -0000 Message-ID: <20031202190742.26569.qmail@minotaur.apache.org> From: jwoolley@apache.org To: httpd-2.0-cvs@apache.org Subject: cvs commit: httpd-2.0/modules/experimental mod_mem_cache.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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)