From: Vsevolod Stakhov Date: Sat, 13 May 2017 12:31:51 +0000 (+0100) Subject: [Minor] Renumber evictions list on removal X-Git-Tag: 1.6.0~218 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1d128aec74a30a714c8677bae78042d1a15941eb;p=rspamd.git [Minor] Renumber evictions list on removal --- diff --git a/src/libutil/hash.c b/src/libutil/hash.c index 1f4fdc22b..c2dd39d07 100644 --- a/src/libutil/hash.c +++ b/src/libutil/hash.c @@ -70,6 +70,7 @@ rspamd_lru_hash_remove_evicted (rspamd_lru_hash_t *hash, rspamd_lru_element_t *elt) { guint i; + rspamd_lru_element_t *cur; g_assert (hash->eviction_used > 0); g_assert (elt->eviction_pos < hash->eviction_used); @@ -82,15 +83,17 @@ rspamd_lru_hash_remove_evicted (rspamd_lru_hash_t *hash, hash->eviction_used--; if (hash->eviction_used > 0) { - if (elt->lg_usages <= hash->eviction_min_prio) { - /* We also need to update min_prio */ - hash->eviction_min_prio = G_MAXUINT; + /* We also need to update min_prio and renumber eviction list */ + hash->eviction_min_prio = G_MAXUINT; - for (i = 0; i < hash->eviction_used; i ++) { - if (hash->eviction_min_prio > hash->eviction_pool[i]->lg_usages) { - hash->eviction_min_prio = hash->eviction_pool[i]->lg_usages; - } + for (i = 0; i < hash->eviction_used; i ++) { + cur = hash->eviction_pool[i]; + + if (hash->eviction_min_prio > cur->lg_usages) { + hash->eviction_min_prio = cur->lg_usages; } + + cur->eviction_pos = i; } } else {