summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d882585)
raw | patch | inline | side by side (parent: d882585)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 14 Oct 2012 14:42:35 +0000 (16:42 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 14 Oct 2012 14:42:35 +0000 (16:42 +0200) |
This ensures that the actual interval for each plugin is available through its
context. It is a preparation for removing 'interval_g' (which has limited use
after introducing per-plugin intervals and, thus, its use is rather error-
prone).
context. It is a preparation for removing 'interval_g' (which has limited use
after introducing per-plugin intervals and, thus, its use is rather error-
prone).
src/configfile.c | patch | blob | history | |
src/plugin.c | patch | blob | history |
diff --git a/src/configfile.c b/src/configfile.c
index 2a03035c6659ce4c85edc9e979b3f99ff440b206..b09bee8dbf66997ab96bea8ef33740d6d4ae362c 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
const char *name;
unsigned int flags = 0;
plugin_ctx_t ctx;
+ plugin_ctx_t old_ctx;
+ int ret_val;
+
assert (strcasecmp (ci->key, "LoadPlugin") == 0);
if (ci->values_num != 1)
return (-1);
name = ci->values[0].value.string;
- ctx.interval = 0;
+
+ /* default to the global interval set before loading this plugin */
+ ctx.interval = plugin_get_interval ();
/*
* XXX: Magic at work:
}
}
- plugin_set_ctx (ctx);
- return (plugin_load (name, (uint32_t) flags));
+ old_ctx = plugin_set_ctx (ctx);
+ ret_val = plugin_load (name, (uint32_t) flags);
+ /* reset to the "global" context */
+ plugin_set_ctx (old_ctx);
+
+ return (ret_val);
} /* int dispatch_value_loadplugin */
static int dispatch_value_plugin (const char *plugin, oconfig_item_t *ci)
diff --git a/src/plugin.c b/src/plugin.c
index 9c2af5d7b8c6b3617512df94ee5dc27c1fbd380b..abb0b1b7d17a6a3fbc2b0ef5709216a17ae82df3 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
if ((rf->rf_interval.tv_sec == 0) && (rf->rf_interval.tv_nsec == 0))
{
+ /* this should not happen, because the interval is set
+ * for each plugin when loading it
+ * XXX: issue a warning? */
now = cdtime ();
CDTIME_T_TO_TIMESPEC (plugin_get_interval (), &rf->rf_interval);
struct timespec interval;
user_data_t user_data;
- DEBUG ("plugin_register_read: plugin_interval = %.3f",
- CDTIME_T_TO_DOUBLE(plugin_interval));
-
user_data.data = callback;
user_data.free_func = NULL;
name, read_cb_wrapper, &interval, &user_data);
}
+ DEBUG ("plugin_register_read: default_interval = %.3f",
+ CDTIME_T_TO_DOUBLE(plugin_get_interval ()));
+
rf = malloc (sizeof (*rf));
if (rf == NULL)
{
}
rf->rf_effective_interval = rf->rf_interval;
+ DEBUG ("plugin_register_read: interval = %i.%09i",
+ (int) rf->rf_interval.tv_sec,
+ (int) rf->rf_interval.tv_nsec);
+
/* Set user data */
if (user_data == NULL)
{