]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix eviction
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 12 May 2017 10:00:13 +0000 (11:00 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 12 May 2017 10:00:13 +0000 (11:00 +0100)
src/libutil/hash.c

index 09377f1e5c342555ca3330688fd9cdbd74381605..1de90b6059bde92054e20fe848b7e3f0871f7614 100644 (file)
@@ -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;
 }