summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 27ee073)
raw | patch | inline | side by side (parent: 27ee073)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 14 Oct 2012 14:31:01 +0000 (16:31 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 14 Oct 2012 14:31:01 +0000 (16:31 +0200) |
This function returns the current value of the plugin's interval. If no
interval has been set in the plugin context, it will fall back to the global
interval or ten seconds as a last resort.
interval has been set in the plugin context, it will fall back to the global
interval or ten seconds as a last resort.
src/plugin.c | patch | blob | history | |
src/plugin.h | patch | blob | history |
diff --git a/src/plugin.c b/src/plugin.c
index 175a89a195ebee99c52c46047fa60ea4fe44f7c5..002955d5164f96fb66096d0d1224350fd83c4399 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
return (old);
} /* void plugin_set_ctx */
+cdtime_t plugin_get_interval (void)
+{
+ cdtime_t interval;
+
+ const char *interval_str;
+ double interval_dbl;
+
+ interval = plugin_get_ctx().interval;
+ if (interval > 0)
+ return interval;
+
+ /* this should happen during initialization only */
+ interval_str = global_option_get ("Interval");
+ if (interval_str != NULL)
+ {
+ interval_dbl = atof (interval_str);
+ if (interval_dbl > 0.0)
+ interval = DOUBLE_TO_CDTIME_T (interval_dbl);
+ }
+
+ if (interval > 0)
+ return interval;
+ return TIME_T_TO_CDTIME_T (10);
+} /* cdtime_t plugin_get_interval */
+
typedef struct {
plugin_ctx_t ctx;
void *(*start_routine) (void *);
diff --git a/src/plugin.h b/src/plugin.h
index 5036a63b56b1b783a7bc7a6cbc728a1cd0544c48..e147a938c433222a04fd919b60faa62703f95f9b 100644 (file)
--- a/src/plugin.h
+++ b/src/plugin.h
plugin_ctx_t plugin_get_ctx (void);
plugin_ctx_t plugin_set_ctx (plugin_ctx_t ctx);
+/*
+ * NAME
+ * plugin_get_interval
+ *
+ * DESCRIPTION
+ * This function returns the current value of the plugin's interval. The
+ * return value will be strictly greater than zero in all cases. If
+ * everything else fails, it will fall back to 10 seconds.
+ */
+cdtime_t plugin_get_interval (void);
+
/*
* Context-aware thread management.
*/