summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 81346b2)
raw | patch | inline | side by side (parent: 81346b2)
author | Florian Forster <octo@collectd.org> | |
Sat, 6 Oct 2012 15:38:50 +0000 (17:38 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Sat, 6 Oct 2012 15:38:50 +0000 (17:38 +0200) |
Also add assertions to make sure plugin_init_ctx() is used correctly.
src/plugin.c | patch | blob | history |
diff --git a/src/plugin.c b/src/plugin.c
index 5387f9c4b8a0c6e8c6c6922dda3604400a8486d1..175a89a195ebee99c52c46047fa60ea4fe44f7c5 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
static int read_threads_num = 0;
static pthread_key_t plugin_ctx_key;
+static _Bool plugin_ctx_key_initialized = 0;
/*
* Static functions
dlh = lt_dlopenadvise(file, advise);
lt_dladvise_destroy(&advise);
} else {
- dlh = lt_dlopen (file);
+ dlh = lt_dlopen (file);
}
#else /* if LIBTOOL_VERSION == 1 */
if (flags & PLUGIN_FLAGS_GLOBAL)
int status;
if (ctx.interval != 0) {
+ /* If ctx.interval is not zero (== use interval_g), we need to
+ * use the "complex" read callback, because only that allows to
+ * specify a different interval. Wrap the callback using
+ * read_cb_wrapper(). */
struct timespec interval;
user_data_t user_data;
}
*ctx = ctx_init;
+ assert (plugin_ctx_key_initialized);
pthread_setspecific (plugin_ctx_key, ctx);
DEBUG("Created new plugin context.");
return (ctx);
void plugin_init_ctx (void)
{
pthread_key_create (&plugin_ctx_key, plugin_ctx_destructor);
+ plugin_ctx_key_initialized = 1;
} /* void plugin_init_ctx */
plugin_ctx_t plugin_get_ctx (void)
{
plugin_ctx_t *ctx;
+ assert (plugin_ctx_key_initialized);
ctx = pthread_getspecific (plugin_ctx_key);
if (ctx == NULL) {
plugin_ctx_t *c;
plugin_ctx_t old;
+ assert (plugin_ctx_key_initialized);
c = pthread_getspecific (plugin_ctx_key);
if (c == NULL) {