summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6054304)
raw | patch | inline | side by side (parent: 6054304)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 20 Dec 2013 17:25:25 +0000 (18:25 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 20 Dec 2013 17:25:25 +0000 (18:25 +0100) |
src/core/plugin.c | patch | blob | history |
diff --git a/src/core/plugin.c b/src/core/plugin.c
index 8200338a9d8fbb0804869b96f9267ed7b776e683..46976d01f7435c580e088f3aebd7836ad14ebbf4 100644 (file)
--- a/src/core/plugin.c
+++ b/src/core/plugin.c
static pthread_key_t plugin_ctx_key;
static _Bool plugin_ctx_key_initialized = 0;
+/* a list of the plugin contexts of all registered plugins */
+static sdb_llist_t *all_plugins = NULL;
+
static sdb_llist_t *config_list = NULL;
static sdb_llist_t *init_list = NULL;
static sdb_llist_t *collector_list = NULL;
};
static ctx_t *
-ctx_create(void)
+ctx_create(const char *name)
{
ctx_t *ctx;
- ctx = CTX(sdb_object_create("plugin-context", ctx_type));
+ ctx = CTX(sdb_object_create(name, ctx_type));
if (! ctx)
return NULL;
if (ctx_get())
sdb_log(SDB_LOG_WARNING, "core: Discarding old plugin context");
- ctx = ctx_create();
+ ctx = ctx_create(real_name);
if (! ctx) {
sdb_log(SDB_LOG_ERR, "core: Failed to initialize plugin context");
return -1;
name, SDB_VERSION_DECODE(ctx->info.version),
SDB_VERSION_DECODE(SDB_VERSION));
+ if (! all_plugins) {
+ if (! (all_plugins = sdb_llist_create())) {
+ sdb_log(SDB_LOG_ERR, "core: Failed to load plugin '%s': "
+ "internal error while creating linked list", name);
+ plugin_unregister_by_name(ctx->info.plugin_name);
+ sdb_object_deref(SDB_OBJ(ctx));
+ return -1;
+ }
+ }
+
+ sdb_llist_append(all_plugins, SDB_OBJ(ctx));
+
sdb_log(SDB_LOG_INFO, "core: Successfully loaded "
"plugin '%s' v%i (%s)\n\t%s\n\tLicense: %s",
INFO_GET(&ctx->info, name), ctx->info.plugin_version,
plugin = SDB_PLUGIN_CB(sdb_llist_search_by_name(config_list, name));
if (! plugin) {
/* XXX: check if any such plugin has been loaded */
- sdb_log(SDB_LOG_ERR, "core: Plugin '%s' did not register "
- "a config callback.", name);
+ ctx_t *ctx = CTX(sdb_llist_search_by_name(all_plugins, name));
+ if (! ctx)
+ sdb_log(SDB_LOG_ERR, "core: Plugin '%s' not loaded.", name);
+ else
+ sdb_log(SDB_LOG_ERR, "core: Plugin '%s' did not register "
+ "a config callback.", name);
errno = ENOENT;
return -1;
}