diff options
author | Ilya Mashchenko <ilya@netdata.cloud> | 2022-04-25 16:59:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-25 16:59:54 +0300 |
commit | 7b7fbd6086207cf05a18fe1344833edfe03a8264 (patch) | |
tree | c9a74f76708fd182eff93783e9da381fc4418d4c /libnetdata | |
parent | 5e8b714acc6a385013c7ddda596f335b298284b6 (diff) |
fix(cgroups.plugin): remove "enable cgroup X" config option on cgroup deletion (#12746)
Diffstat (limited to 'libnetdata')
-rw-r--r-- | libnetdata/config/appconfig.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/libnetdata/config/appconfig.c b/libnetdata/config/appconfig.c index 0daa6e5e48..b710190d0a 100644 --- a/libnetdata/config/appconfig.c +++ b/libnetdata/config/appconfig.c @@ -257,6 +257,54 @@ void appconfig_section_destroy_non_loaded(struct config *root, const char *secti freez(co); } +void appconfig_section_option_destroy_non_loaded(struct config *root, const char *section, const char *name) +{ + debug(D_CONFIG, "Destroying section option '%s -> %s'.", section, name); + + struct section *co; + co = appconfig_section_find(root, section); + if (!co) { + error("Could not destroy section option '%s -> %s'. The section not found.", section, name); + return; + } + + config_section_wrlock(co); + + struct config_option *cv; + + cv = appconfig_option_index_find(co, name, simple_hash(name)); + + if (cv && cv->flags & CONFIG_VALUE_LOADED) { + config_section_unlock(co); + return; + } + + if (unlikely(!(cv && appconfig_option_index_del(co, cv)))) { + config_section_unlock(co); + error("Could not destroy section option '%s -> %s'. The option not found.", section, name); + return; + } + + if (co->values == cv) { + co->values = co->values->next; + } else { + struct config_option *cv_cur = co->values, *cv_prev = NULL; + while (cv_cur && cv_cur != cv) { + cv_prev = cv_cur; + cv_cur = cv_cur->next; + } + if (cv_cur) { + cv_prev->next = cv_cur->next; + } + } + + freez(cv->value); + freez(cv->name); + freez(cv); + + config_section_unlock(co); + return; +} // ---------------------------------------------------------------------------- // config name-value methods |