]> source.dussan.org Git - rspamd.git/commitdiff
Expire an element if forced expire is required.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 30 Nov 2011 12:11:54 +0000 (15:11 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 30 Nov 2011 12:11:54 +0000 (15:11 +0300)
src/kvstorage.c

index 5ad076b3ed5dbfbb9503869f9b70e30237b40384..7c8b3ef80ee2d4857ce71b0843754ce98fbfcf88 100644 (file)
@@ -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 {