From c36131d2bd53707f71ad9c63875db5d506f3b45f Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 22 Jul 2019 16:10:20 +0100 Subject: [PATCH] [Fix] Fix eviction corner case Issue: #2991 --- src/libutil/hash.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libutil/hash.c b/src/libutil/hash.c index 56e80a17e..09d3a29c1 100644 --- a/src/libutil/hash.c +++ b/src/libutil/hash.c @@ -481,6 +481,10 @@ rspamd_lru_hash_evict (rspamd_lru_hash_t *hash, time_t now) } } }); + + if (selected) { + elt = selected; + } } else { /* Fast random eviction */ @@ -493,6 +497,7 @@ rspamd_lru_hash_evict (rspamd_lru_hash_t *hash, time_t now) } } + /* Evict if nothing else has been cleaned */ if (elt && nexpired == 0) { rspamd_lru_hash_remove_node (hash, elt); } -- 2.39.5