summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-02-06 12:40:03 +1100
committerJeremy Allison <jra@samba.org>2010-02-10 15:38:31 -0800
commit7842b391b9ad1f6aaa77c0b8397e1dcc0b79e7e7 (patch)
tree3821d65069f3166220ae07686160269af0cfdbc5 /source3/lib
parent54fc99e04b3475a9cc04274fa365edbd700d3491 (diff)
downloadsamba-7842b391b9ad1f6aaa77c0b8397e1dcc0b79e7e7.tar.gz
samba-7842b391b9ad1f6aaa77c0b8397e1dcc0b79e7e7.tar.bz2
samba-7842b391b9ad1f6aaa77c0b8397e1dcc0b79e7e7.zip
s3-memcache: update memcache to use new DLIST macros
we don't need a separate lru pointer any more (cherry picked from commit 4ffd7aca3e38728077bd80c2a65c4efbcfd216fc)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/memcache.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/source3/lib/memcache.c b/source3/lib/memcache.c
index 606d72ab5a..5c4bafa17d 100644
--- a/source3/lib/memcache.c
+++ b/source3/lib/memcache.c
@@ -31,7 +31,7 @@ struct memcache_element {
};
struct memcache {
- struct memcache_element *mru, *lru;
+ struct memcache_element *mru;
struct rb_root tree;
size_t size;
size_t max_size;
@@ -161,16 +161,7 @@ bool memcache_lookup(struct memcache *cache, enum memcache_number n,
}
if (cache->size != 0) {
- /*
- * Do LRU promotion only when we will ever shrink
- */
- if (e == cache->lru) {
- cache->lru = e->prev;
- }
DLIST_PROMOTE(cache->mru, e);
- if (cache->mru == NULL) {
- cache->mru = e;
- }
}
memcache_element_parse(e, &key, value);
@@ -201,9 +192,6 @@ static void memcache_delete_element(struct memcache *cache,
{
rb_erase(&e->rb_node, &cache->tree);
- if (e == cache->lru) {
- cache->lru = e->prev;
- }
DLIST_REMOVE(cache->mru, e);
if (memcache_is_talloc(e->n)) {
@@ -227,8 +215,8 @@ static void memcache_trim(struct memcache *cache)
return;
}
- while ((cache->size > cache->max_size) && (cache->lru != NULL)) {
- memcache_delete_element(cache, cache->lru);
+ while ((cache->size > cache->max_size) && DLIST_TAIL(cache->mru)) {
+ memcache_delete_element(cache, DLIST_TAIL(cache->mru));
}
}
@@ -331,9 +319,6 @@ void memcache_add(struct memcache *cache, enum memcache_number n,
rb_insert_color(&e->rb_node, &cache->tree);
DLIST_ADD(cache->mru, e);
- if (cache->lru == NULL) {
- cache->lru = e;
- }
cache->size += element_size;
memcache_trim(cache);