summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2022-07-14 00:02:59 +0300
committerCosta Tsaousis <costa@netdata.cloud>2022-07-14 00:02:59 +0300
commit0c0f519bc55d15cd6cdc7fccfa547def9c0f02a1 (patch)
treecf2058a8a0bfb6343fd74b321d69422b9673fe48
parent481ffbd540601da97bc82e45caeede13390da622 (diff)
prevent crash on charts cleanup
-rw-r--r--database/rrdhost.c4
-rw-r--r--database/rrdset.c5
2 files changed, 5 insertions, 4 deletions
diff --git a/database/rrdhost.c b/database/rrdhost.c
index 762081316b..296cf81305 100644
--- a/database/rrdhost.c
+++ b/database/rrdhost.c
@@ -1126,8 +1126,6 @@ void rrdhost_free(RRDHOST *host) {
// ------------------------------------------------------------------------
// free it
- rrdhost_destroy_rrdcontexts(host);
-
pthread_mutex_destroy(&host->aclk_state_lock);
freez(host->aclk_state.claimed_id);
freez(host->aclk_state.prev_claimed_id);
@@ -1154,6 +1152,8 @@ void rrdhost_free(RRDHOST *host) {
netdata_rwlock_destroy(&host->rrdhost_rwlock);
freez(host->node_id);
+ rrdhost_destroy_rrdcontexts(host);
+
freez(host);
#ifdef ENABLE_ACLK
if (wc)
diff --git a/database/rrdset.c b/database/rrdset.c
index 4bf1423ef7..6a437555b5 100644
--- a/database/rrdset.c
+++ b/database/rrdset.c
@@ -337,8 +337,6 @@ static inline void last_updated_time_align(RRDSET *st) {
void rrdset_free(RRDSET *st) {
if(unlikely(!st)) return;
- rrdcontext_removed_rrdset(st);
-
RRDHOST *host = st->rrdhost;
rrdhost_check_wrlock(host); // make sure we have a write lock on the host
@@ -389,6 +387,9 @@ void rrdset_free(RRDSET *st) {
rrdset_unlock(st);
+ // this has to be after the dimensions are freed
+ rrdcontext_removed_rrdset(st);
+
// ------------------------------------------------------------------------
// free it