Code

Make all plugins ready for reconfiguration support.
authorSebastian Harl <sh@tokkee.org>
Mon, 21 Apr 2014 17:36:38 +0000 (19:36 +0200)
committerSebastian Harl <sh@tokkee.org>
Mon, 21 Apr 2014 17:36:38 +0000 (19:36 +0200)
That is, handle NULL arguments passed to the config and module init functions
during reconfiguration.

src/backend/collectd/unixsock.c
src/backend/mk-livestatus.c
src/backend/puppet/store-configs.c

index 7c60c5e79b9d14a978644a72915a3ad39202fcb6..0c5082af54c0b9ca99a95ef8fea295ffeeae1e3b 100644 (file)
@@ -347,6 +347,9 @@ sdb_collectd_config(oconfig_item_t *ci)
 {
        int i;
 
 {
        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;
 
        for (i = 0; i < ci->children_num; ++i) {
                oconfig_item_t *child = ci->children + i;
 
index c77951a20246ba7a3e2d4a8a8474cac5900eded4..21c603ad497fab30db9189405ba807b874001f06 100644 (file)
@@ -292,6 +292,9 @@ sdb_livestatus_config(oconfig_item_t *ci)
 {
        int i;
 
 {
        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;
 
        for (i = 0; i < ci->children_num; ++i) {
                oconfig_item_t *child = ci->children + i;
 
index e109b305819cfcec5fb1d7f32403241ed519d69b..5506b0a939e984254f2c8646a7ba954a130dbc77 100644 (file)
@@ -343,6 +343,9 @@ sdb_puppet_stcfg_config(oconfig_item_t *ci)
 {
        int i;
 
 {
        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;
 
        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);
 
        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.");
                sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: failed to "
                                "initialize DBI; possibly you don't have any drivers "
                                "installed.");