From 83ba6762cc43d9db581b979bb5e3445669e46cc2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 25 Nov 2024 18:33:56 +0100 Subject: Merging upstream version 2.0.3+dfsg (Closes: #923993, #1042533, #1045145). Signed-off-by: Daniel Baumann --- src/database/rrddim.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/database/rrddim.c') diff --git a/src/database/rrddim.c b/src/database/rrddim.c index 580319d30..7b98b64d0 100644 --- a/src/database/rrddim.c +++ b/src/database/rrddim.c @@ -41,6 +41,13 @@ static void rrddim_insert_callback(const DICTIONARY_ITEM *item __maybe_unused, v RRDSET *st = ctr->st; RRDHOST *host = st->rrdhost; + rd->dimension_id = __atomic_add_fetch(&host->accounting.dimension_count, 1, __ATOMIC_RELAXED); + spinlock_lock(&host->accounting.spinlock); + Pvoid_t *Pvalue = JudyLIns(&host->accounting.JudyL, rd->dimension_id, PJE0); + if (Pvalue) + *Pvalue = rd; + spinlock_unlock(&host->accounting.spinlock); + rd->flags = RRDDIM_FLAG_NONE; rd->id = string_strdupz(ctr->id); @@ -231,6 +238,10 @@ static void rrddim_delete_callback(const DICTIONARY_ITEM *item __maybe_unused, v freez(rd->db.data); } + spinlock_lock(&host->accounting.spinlock); + (void) JudyLDel(&host->accounting.JudyL, rd->dimension_id, PJE0); + spinlock_unlock(&host->accounting.spinlock); + string_freez(rd->id); string_freez(rd->name); } @@ -557,6 +568,12 @@ collected_number rrddim_timed_set_by_pointer(RRDSET *st __maybe_unused, RRDDIM * rrddim_set_updated(rd); rd->collector.counter++; +// spinlock_lock(&st->rrdhost->accounting.spinlock); +// Pvoid_t *Pvalue = JudyLIns(&st->rrdhost->accounting.JudySecL, (Word_t) collected_time.tv_sec, PJE0); +// if (Pvalue) +// *((int64_t *)Pvalue) = *((int64_t *)Pvalue) + 1; +// spinlock_unlock(&st->rrdhost->accounting.spinlock); + collected_number v = (value >= 0) ? value : -value; if (unlikely(v > rd->collector.collected_value_max)) rd->collector.collected_value_max = v; -- cgit v1.2.3