Skip to content
Snippets Groups Projects
Commit f705bc32 authored by Daniel Salzman's avatar Daniel Salzman
Browse files

conf: fix memory leak with utils

parent e14bec1c
No related branches found
No related tags found
No related merge requests found
......@@ -262,14 +262,14 @@ int conf_clone(
out->filename = strdup(s_conf->filename);
}
// Initialize query modules list.
init_list(&out->query_modules);
// Reuse the hostname.
// Copy the hostname.
if (s_conf->hostname != NULL) {
out->hostname = strdup(s_conf->hostname);
}
// Initialize query modules list.
init_list(&out->query_modules);
// Initialize cached values.
init_cache(out);
......@@ -283,19 +283,19 @@ int conf_clone(
void conf_update(
conf_t *conf)
{
if (conf == NULL) {
return;
// Remove the clone flag for new master configuration.
if (conf != NULL) {
conf->is_clone = false;
}
conf->is_clone = false;
conf_t **current_conf = &s_conf;
conf_t *old_conf = rcu_xchg_pointer(current_conf, conf);
synchronize_rcu();
if (old_conf) {
old_conf->is_clone = true;
if (old_conf != NULL) {
// Remove the clone flag if a single configuration.
old_conf->is_clone = (conf != NULL) ? true : false;
conf_free(old_conf);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment