From: Vsevolod Stakhov Date: Fri, 12 May 2017 10:00:13 +0000 (+0100) Subject: [Minor] Fix eviction X-Git-Tag: 1.6.0~228 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f6bcc7cd0937d1d4657f815d5d00f2aed7228dd9;p=rspamd.git [Minor] Fix eviction --- diff --git a/src/libutil/hash.c b/src/libutil/hash.c index 09377f1e5..1de90b605 100644 --- a/src/libutil/hash.c +++ b/src/libutil/hash.c @@ -130,7 +130,7 @@ rspamd_lru_hash_maybe_evict (rspamd_lru_hash_t *hash, guint i; rspamd_lru_element_t *cur; - if (elt->eviction_pos != -1) { + if (elt->eviction_pos == -1) { if (hash->eviction_used < eviction_candidates) { /* There are free places in eviction pool */ hash->eviction_pool[hash->eviction_used] = elt; @@ -159,6 +159,10 @@ rspamd_lru_hash_maybe_evict (rspamd_lru_hash_t *hash, } } } + else { + /* Already in the eviction list */ + return TRUE; + } return FALSE; } @@ -184,6 +188,7 @@ rspamd_lru_create_node (rspamd_lru_hash_t *hash, node->hash = hash; node->lg_usages = lfu_base_value; node->last = TIME_TO_TS (now); + node->eviction_pos = -1; return node; }