From: Sebastian Harl Date: Tue, 22 Apr 2014 22:13:50 +0000 (+0200) Subject: backends: Destroy dbi/unixsock clients on shutdown. X-Git-Tag: sysdb-0.1.0~95 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a0c8961e4732d71aaed1f4cda663203ff722b23e;p=sysdb.git backends: Destroy dbi/unixsock clients on shutdown. This would also be cleaned up when destroying the registered user data objects but doing so on shutdown in much cleaner. --- diff --git a/src/backend/collectd/unixsock.c b/src/backend/collectd/unixsock.c index 6fc2ef9..8ac829d 100644 --- a/src/backend/collectd/unixsock.c +++ b/src/backend/collectd/unixsock.c @@ -192,6 +192,11 @@ sdb_collectd_init(sdb_object_t *user_data) static int sdb_collectd_shutdown(__attribute__((unused)) sdb_object_t *user_data) { + if (! user_data) + return -1; + + sdb_unixsock_client_destroy(SDB_OBJ_WRAPPER(user_data)->data); + SDB_OBJ_WRAPPER(user_data)->data = NULL; return 0; } /* sdb_collectd_shutdown */ diff --git a/src/backend/mk-livestatus.c b/src/backend/mk-livestatus.c index 21c603a..e631ae7 100644 --- a/src/backend/mk-livestatus.c +++ b/src/backend/mk-livestatus.c @@ -146,6 +146,17 @@ sdb_livestatus_init(sdb_object_t *user_data) return 0; } /* sdb_livestatus_init */ +static int +sdb_livestatus_shutdown(sdb_object_t *user_data) +{ + if (! user_data) + return -1; + + sdb_unixsock_client_destroy(SDB_OBJ_WRAPPER(user_data)->data); + SDB_OBJ_WRAPPER(user_data)->data = NULL; + return 0; +} /* sdb_livestatus_shutdown */ + static int sdb_livestatus_collect(sdb_object_t *user_data) { @@ -279,6 +290,7 @@ sdb_livestatus_config_instance(oconfig_item_t *ci) } sdb_plugin_register_init(cb_name, sdb_livestatus_init, user_data); + sdb_plugin_register_shutdown(cb_name, sdb_livestatus_shutdown, user_data); sdb_plugin_register_collector(cb_name, sdb_livestatus_collect, /* interval */ NULL, user_data); diff --git a/src/backend/puppet/store-configs.c b/src/backend/puppet/store-configs.c index 5506b0a..0f95ae5 100644 --- a/src/backend/puppet/store-configs.c +++ b/src/backend/puppet/store-configs.c @@ -138,6 +138,17 @@ sdb_puppet_stcfg_init(sdb_object_t *user_data) return 0; } /* sdb_puppet_stcfg_init */ +static int +sdb_puppet_stcfg_shutdown(sdb_object_t *user_data) +{ + if (! user_data) + return -1; + + sdb_dbi_client_destroy(SDB_OBJ_WRAPPER(user_data)->data); + SDB_OBJ_WRAPPER(user_data)->data = NULL; + return 0; +} /* sdb_puppet_stcfg_shutdown */ + static int sdb_puppet_stcfg_collect(sdb_object_t *user_data) { @@ -330,6 +341,8 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci) } sdb_plugin_register_init(cb_name, sdb_puppet_stcfg_init, user_data); + sdb_plugin_register_shutdown(cb_name, sdb_puppet_stcfg_shutdown, + user_data); sdb_plugin_register_collector(cb_name, sdb_puppet_stcfg_collect, /* interval */ NULL, user_data);