From 2975827e40a8e7c6e820c42921fb8792cf637450 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 30 Nov 2011 15:11:54 +0300 Subject: [PATCH] Expire an element if forced expire is required. --- src/kvstorage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kvstorage.c b/src/kvstorage.c index 5ad076b3e..7c8b3ef80 100644 --- a/src/kvstorage.c +++ b/src/kvstorage.c @@ -132,7 +132,7 @@ rspamd_kv_storage_insert_cache (struct rspamd_kv_storage *storage, gpointer key, } storage->elts ++; - storage->memory += elt->size + sizeof (struct rspamd_kv_element); + storage->memory += ELT_SIZE (elt); g_static_rw_lock_writer_unlock (&storage->rwlock); return TRUE; @@ -585,7 +585,7 @@ rspamd_lru_expire_step (struct rspamd_kv_expire *e, struct rspamd_kv_storage *st elt = TAILQ_FIRST (&expire->head); if (elt && (forced || (elt->flags & (KV_ELT_PERSISTENT|KV_ELT_DIRTY)) == 0)) { diff = elt->expire - (now - elt->age); - if (diff > 0) { + if (diff > 0 || (forced && elt->expire == 0)) { oldest_elt = elt; } else { -- 2.39.5