summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2fde302)
raw | patch | inline | side by side (parent: 2fde302)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 18 Apr 2014 11:57:00 +0000 (13:57 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 18 Apr 2014 11:57:00 +0000 (13:57 +0200) |
Also, let plugin_load return early if the plugin is already loaded.
This is mostly in preparation for future improvements around plugin handling.
This is mostly in preparation for future improvements around plugin handling.
src/core/plugin.c | patch | blob | history |
diff --git a/src/core/plugin.c b/src/core/plugin.c
index 6af090bfac233eec2e51a91221e4a762ee3f02f7..a521b89d1f00778233e7465cb3eb25e7692cd74c 100644 (file)
--- a/src/core/plugin.c
+++ b/src/core/plugin.c
sdb_plugin_ctx_t public;
sdb_plugin_info_t info;
+
+ /* The usage count differs from the object's ref count
+ * in that it provides higher level information about how
+ * the plugin is in use. */
+ size_t use_cnt;
} ctx_t;
#define CTX_INIT { SDB_OBJECT_INIT, \
- SDB_PLUGIN_CTX_INIT, SDB_PLUGIN_INFO_INIT }
+ SDB_PLUGIN_CTX_INIT, SDB_PLUGIN_INFO_INIT, 0 }
#define CTX(obj) ((ctx_t *)(obj))
ctx->public = plugin_default_ctx;
ctx->info = plugin_default_info;
+ ctx->use_cnt = 1;
return 0;
} /* ctx_init */
}
strcat(real_name, name_ptr);
+ ctx = CTX(sdb_llist_search_by_name(all_plugins, real_name));
+ if (ctx) {
+ /* plugin already loaded */
+ ++ctx->use_cnt;
+ return 0;
+ }
+
snprintf(filename, sizeof(filename), "%s/%s.so",
PKGLIBDIR, real_name);
filename[sizeof(filename) - 1] = '\0';