diff options
Diffstat (limited to 'database/rrdhost.c')
-rw-r--r-- | database/rrdhost.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/database/rrdhost.c b/database/rrdhost.c index df4e364d9b..a7fac8569b 100644 --- a/database/rrdhost.c +++ b/database/rrdhost.c @@ -890,6 +890,26 @@ struct label *create_label(char *key, char *value, LABEL_SOURCE label_source) return result; } +void free_host_labels(struct label *labels) +{ + while (labels != NULL) + { + struct label *current = labels; + labels = labels->next; + freez(current); + } +} + +void replace_label_list(RRDHOST *host, struct label *new_labels) +{ + netdata_rwlock_wrlock(&host->labels_rwlock); + struct label *old_labels = host->labels; + host->labels = new_labels; + netdata_rwlock_unlock(&host->labels_rwlock); + + free_host_labels(old_labels); +} + struct label *add_label_to_list(struct label *l, char *key, char *value, LABEL_SOURCE label_source) { struct label *lab = create_label(key, value, label_source); @@ -937,16 +957,11 @@ void reload_host_labels() struct label *new_labels = merge_label_lists(from_auto, from_k8s); new_labels = merge_label_lists(new_labels, from_config); - netdata_rwlock_wrlock(&localhost->labels_rwlock); - struct label *old_labels = localhost->labels; - localhost->labels = new_labels; - netdata_rwlock_unlock(&localhost->labels_rwlock); + replace_label_list(localhost, new_labels); - while (old_labels != NULL) - { - struct label *current = old_labels; - old_labels = old_labels->next; - freez(current); + if(localhost->rrdpush_send_enabled && localhost->rrdpush_sender_buffer){ + localhost->labels_flag |= LABEL_FLAG_UPDATE_STREAM; + rrdpush_send_labels(localhost); } health_reload(); |