From: Sebastian Harl Date: Sun, 1 Feb 2015 10:31:23 +0000 (+0100) Subject: Unload all plugins when shutting down sysdbd. X-Git-Tag: sysdb-0.7.0~20 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=eae5d03ff51ed65e77058aebb944dffa0a9bb142;p=sysdb.git Unload all plugins when shutting down sysdbd. This will destruct all registered user-data objects, thus properly shutting down all internal plugin state (e.g. connections to other systems). --- diff --git a/src/core/plugin.c b/src/core/plugin.c index da77f8e..bf0bdb3 100644 --- a/src/core/plugin.c +++ b/src/core/plugin.c @@ -251,26 +251,6 @@ plugin_unregister_by_name(const char *plugin_name) /* else: other callbacks still reference it */ } /* plugin_unregister_by_name */ -static void -plugin_unregister_all(void) -{ - size_t i; - - for (i = 0; i < SDB_STATIC_ARRAY_LEN(all_lists); ++i) { - const char *type = all_lists[i].type; - sdb_llist_t *list = *all_lists[i].list; - - size_t len = sdb_llist_len(list); - - if (! len) - continue; - - sdb_llist_clear(list); - sdb_log(SDB_LOG_INFO, "core: Unregistered %zu %s callback%s", - len, type, len == 1 ? "" : "s"); - } -} /* plugin_unregister_all */ - /* * private types */ @@ -889,6 +869,26 @@ sdb_plugin_register_writer(const char *name, return 0; } /* sdb_store_register_writer */ +void +sdb_plugin_unregister_all(void) +{ + size_t i; + + for (i = 0; i < SDB_STATIC_ARRAY_LEN(all_lists); ++i) { + const char *type = all_lists[i].type; + sdb_llist_t *list = *all_lists[i].list; + + size_t len = sdb_llist_len(list); + + if (! len) + continue; + + sdb_llist_clear(list); + sdb_log(SDB_LOG_INFO, "core: Unregistered %zu %s callback%s", + len, type, len == 1 ? "" : "s"); + } +} /* sdb_plugin_unregister_all */ + sdb_plugin_ctx_t sdb_plugin_get_ctx(void) { @@ -997,7 +997,7 @@ sdb_plugin_reconfigure_init(void) CTX(sdb_llist_iter_get_next(iter))->use_cnt = 0; sdb_llist_iter_destroy(iter); - plugin_unregister_all(); + sdb_plugin_unregister_all(); return 0; } /* sdb_plugin_reconfigure_init */ diff --git a/src/include/core/plugin.h b/src/include/core/plugin.h index f48980a..1155a95 100644 --- a/src/include/core/plugin.h +++ b/src/include/core/plugin.h @@ -275,6 +275,13 @@ int sdb_plugin_register_writer(const char *name, sdb_store_writer_t *writer, sdb_object_t *user_data); +/* + * sdb_plugin_unregister_all: + * Unregister all registered plugins and destruct their user-data objects. + */ +void +sdb_plugin_unregister_all(void); + /* * sdb_plugin_get_ctx, sdb_plugin_set_ctx: * The plugin context defines a set of settings that are available whenever a diff --git a/src/tools/sysdbd/main.c b/src/tools/sysdbd/main.c index 3e90439..25f6499 100644 --- a/src/tools/sysdbd/main.c +++ b/src/tools/sysdbd/main.c @@ -396,6 +396,7 @@ main(int argc, char **argv) sdb_log(SDB_LOG_INFO, "Shutting down SysDB daemon "SDB_VERSION_STRING SDB_VERSION_EXTRA" (pid %i)", (int)getpid()); sdb_plugin_shutdown_all(); + sdb_plugin_unregister_all(); ERR_free_strings(); return status;