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)
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)
{