summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 606d72ab5ac..5c4bafa17d0 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);