Fix shutdown (#19306)
revert coverity fix; count also the number of entries to release shutdown
Costa Tsaousis committed
Dec 31, 2024 at 15:57 UTC
3ad344a120280aa10e897b01a89573c9f9f4a617
2 files changed
+5
-2
src/daemon/daemon-shutdown.c
+3
-1
@@ -86,6 +86,7 @@ static void rrdeng_flush_everything_and_wait(bool wait_flush, bool wait_collecto
86
87
struct pgc_statistics pgc_main_stats = pgc_get_statistics(main_cache);
88
size_t size_to_flush = pgc_main_stats.queues[PGC_QUEUE_HOT].size + pgc_main_stats.queues[PGC_QUEUE_DIRTY].size;
89
+ size_t entries_to_flush = pgc_main_stats.queues[PGC_QUEUE_HOT].entries + pgc_main_stats.queues[PGC_QUEUE_DIRTY].entries;
90
if(size_to_flush > starting_size_to_flush || !starting_size_to_flush)
91
starting_size_to_flush = size_to_flush;
92
@@ -111,10 +112,11 @@ static void rrdeng_flush_everything_and_wait(bool wait_flush, bool wait_collecto
112
for(size_t iterations = 0; true ;iterations++) {
113
pgc_main_stats = pgc_get_statistics(main_cache);
114
size_to_flush = pgc_main_stats.queues[PGC_QUEUE_HOT].size + pgc_main_stats.queues[PGC_QUEUE_DIRTY].size;
115
+ entries_to_flush = pgc_main_stats.queues[PGC_QUEUE_HOT].entries + pgc_main_stats.queues[PGC_QUEUE_DIRTY].entries;
116
if(!starting_size_to_flush || size_to_flush > starting_size_to_flush)
117
starting_size_to_flush = size_to_flush;
118
117
- if(!size_to_flush)
119
+ if(!size_to_flush || !entries_to_flush)
120
break;
121
122
size_t flushed = starting_size_to_flush - size_to_flush;
src/database/engine/cache.c
+2
-1
@@ -706,7 +706,7 @@ static void pgc_queue_del(PGC *cache __maybe_unused, struct pgc_queue *q, PGC_PA
706
DOUBLE_LINKED_LIST_REMOVE_ITEM_UNSAFE(sp->base, page, link.prev, link.next);
707
708
if(!sp->base) {
709
- ssize_t mem_before_judyl, mem_after_judyl;
709
+ size_t mem_before_judyl, mem_after_judyl;
710
711
mem_before_judyl = JudyLMemUsed(q->sections_judy);
712
int rc = JudyLDel(&q->sections_judy, page->section, PJE0);
@@ -717,6 +717,7 @@ static void pgc_queue_del(PGC *cache __maybe_unused, struct pgc_queue *q, PGC_PA
717
718
// freez(sp);
719
aral_freez(pgc_sections_aral, sp);
720
+ mem_after_judyl -= sizeof(struct section_pages);
721
pgc_stats_queue_judy_change(cache, q, mem_before_judyl, mem_after_judyl);
722
}
723
}