aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-12 11:00:13 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-12 11:00:13 +0100
commitf6bcc7cd0937d1d4657f815d5d00f2aed7228dd9 (patch)
tree905ef87c0f9fd5e596c72a63d12956c74c35ea3e /src/libutil
parentc6673ac3149c172056cfa13ec6818b8113aada0d (diff)
downloadrspamd-f6bcc7cd0937d1d4657f815d5d00f2aed7228dd9.tar.gz
rspamd-f6bcc7cd0937d1d4657f815d5d00f2aed7228dd9.zip
[Minor] Fix eviction
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/hash.c7
1 files changed, 6 insertions, 1 deletions
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;
}