From fffcdc97635e9fb40342c6ad55904cdc0b1ef101 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Mon, 21 Apr 2014 19:36:38 +0200 Subject: [PATCH] Make all plugins ready for reconfiguration support. That is, handle NULL arguments passed to the config and module init functions during reconfiguration. --- src/backend/collectd/unixsock.c | 3 +++ src/backend/mk-livestatus.c | 3 +++ src/backend/puppet/store-configs.c | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) 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."); -- 2.30.2