summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-13 13:31:51 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-13 13:31:51 +0100
commit1d128aec74a30a714c8677bae78042d1a15941eb (patch)
treee2c54636e68658c593ad68cd66a04efde8b629a1 /src
parenteb0ec2feb63afdf7d16babbcc82f59950233e0ee (diff)
downloadrspamd-1d128aec74a30a714c8677bae78042d1a15941eb.tar.gz
rspamd-1d128aec74a30a714c8677bae78042d1a15941eb.zip
[Minor] Renumber evictions list on removal
Diffstat (limited to 'src')
-rw-r--r--src/libutil/hash.c17
1 files changed, 10 insertions, 7 deletions
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 {