From: Paul J. Reder Date: Thu, 5 Feb 2004 19:08:37 +0000 (+0000) Subject: *) Fixed cache-removal order in mod_mem_cache. X-Git-Tag: 2.0.49~151 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98eaea0b5d9d0279d100c49ca157a835c75035e8;p=thirdparty%2Fapache%2Fhttpd.git *) Fixed cache-removal order in mod_mem_cache. Submitted by: Jean-Jacques Clar, Cliff Woolley Reviewed by: jwoolley, bnicholes, rederpj git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_2_0_BRANCH@102518 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 056721ee2ae..f1e5a46779f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ Changes with Apache 2.0.49 + *) Fixed cache-removal order in mod_mem_cache. + [Jean-Jacques Clar, Cliff Woolley] + *) mod_setenvif: Fix the regex optimizer, which under circumstances treated the supplied regex as literal string. PR 24219. [André Malo] diff --git a/STATUS b/STATUS index cdd4e6b76aa..4c0b8c7933a 100644 --- a/STATUS +++ b/STATUS @@ -1,5 +1,5 @@ APACHE 2.0 STATUS: -*-text-*- -Last modified at [$Date: 2004/02/05 18:41:58 $] +Last modified at [$Date: 2004/02/05 19:08:36 $] Release: @@ -241,11 +241,6 @@ PATCHES TO BACKPORT FROM 2.1 bnicholes (looks good on Netware but then NetWare does not use shared memory.) - * Fix mod_mem_cache removal ordering bug. - modules/experimental/mod_mem_cache.c r1.97,1.99 - modules/experimental/cache_cache.c r1.5 - +1: jwoolley, bnicholes, rederpj - * mod_auth_digest: Allow sub-requests with different methods than the original request. PR 25040. modules/aaa/mod_auth_digest.c: r1.82 diff --git a/modules/experimental/cache_cache.c b/modules/experimental/cache_cache.c index 78f26e254f7..6189ec8d5a9 100644 --- a/modules/experimental/cache_cache.c +++ b/modules/experimental/cache_cache.c @@ -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, diff --git a/modules/experimental/mod_mem_cache.c b/modules/experimental/mod_mem_cache.c index bcade9febd8..b65680d35c8 100644 --- a/modules/experimental/mod_mem_cache.c +++ b/modules/experimental/mod_mem_cache.c @@ -232,20 +232,21 @@ static void memcache_cache_free(void*a) #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 = 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 @@ 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 -1*mobj->priority; + return mobj->priority; } static void cleanup_cache_object(cache_object_t *obj)