From: Sebastian Harl Date: Mon, 21 Apr 2014 17:36:38 +0000 (+0200) Subject: Make all plugins ready for reconfiguration support. X-Git-Tag: sysdb-0.1.0~108 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fffcdc97635e9fb40342c6ad55904cdc0b1ef101;p=sysdb.git Make all plugins ready for reconfiguration support. That is, handle NULL arguments passed to the config and module init functions during reconfiguration. --- diff --git a/src/backend/collectd/unixsock.c b/src/backend/collectd/unixsock.c index 7c60c5e..0c5082a 100644 --- a/src/backend/collectd/unixsock.c +++ b/src/backend/collectd/unixsock.c @@ -347,6 +347,9 @@ sdb_collectd_config(oconfig_item_t *ci) { int i; + if (! ci) /* nothing to do to deconfigure this plugin */ + return 0; + for (i = 0; i < ci->children_num; ++i) { oconfig_item_t *child = ci->children + i; diff --git a/src/backend/mk-livestatus.c b/src/backend/mk-livestatus.c index c77951a..21c603a 100644 --- a/src/backend/mk-livestatus.c +++ b/src/backend/mk-livestatus.c @@ -292,6 +292,9 @@ sdb_livestatus_config(oconfig_item_t *ci) { int i; + if (! ci) /* nothing to do to deconfigure this plugin */ + return 0; + for (i = 0; i < ci->children_num; ++i) { oconfig_item_t *child = ci->children + i; diff --git a/src/backend/puppet/store-configs.c b/src/backend/puppet/store-configs.c index e109b30..5506b0a 100644 --- a/src/backend/puppet/store-configs.c +++ b/src/backend/puppet/store-configs.c @@ -343,6 +343,9 @@ sdb_puppet_stcfg_config(oconfig_item_t *ci) { int i; + if (! ci) /* nothing to do to deconfigure this plugin */ + return 0; + for (i = 0; i < ci->children_num; ++i) { oconfig_item_t *child = ci->children + i; @@ -367,7 +370,8 @@ sdb_module_init(sdb_plugin_info_t *info) sdb_plugin_set_info(info, SDB_PLUGIN_INFO_VERSION, SDB_VERSION); sdb_plugin_set_info(info, SDB_PLUGIN_INFO_PLUGIN_VERSION, SDB_VERSION); - if (dbi_initialize(/* driver dir = */ NULL) < 0) { + /* don't reinitialize dbi when reinitializing the plugin */ + if (info && (dbi_initialize(/* driver dir = */ NULL) < 0)) { sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: failed to " "initialize DBI; possibly you don't have any drivers " "installed.");