summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f990546)
raw | patch | inline | side by side (parent: f990546)
author | Florian Forster <octo@collectd.org> | |
Mon, 21 Jan 2013 15:38:28 +0000 (16:38 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Mon, 21 Jan 2013 15:38:28 +0000 (16:38 +0100) |
This feels a bit hackish, but it should do the job.
src/plugin.c | patch | blob | history |
diff --git a/src/plugin.c b/src/plugin.c
index 478ec52c252533ef0b42ec292ea01ecfc8812f68..409521b7141bf6890d4a69ff9054f1c4ea33da25 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -629,6 +629,35 @@ static value_list_t *plugin_value_list_clone (value_list_t const *vl_orig) /* {{
return (NULL);
}
+ if (vl->time == 0)
+ vl->time = cdtime ();
+
+ /* Once this gets dequeued by a write thread, we don't have access to
+ * the thread context anymore. We therefore fill in the interval here,
+ * if required. An alternative would be to copy the context and clone
+ * the context in the write thread, but that seems overly complicated
+ * for the interval alone. */
+ if (vl->interval == 0)
+ {
+ plugin_ctx_t ctx = plugin_get_ctx ();
+
+ if (ctx.interval != 0)
+ vl->interval = ctx.interval;
+ else
+ {
+ char name[6 * DATA_MAX_NAME_LEN];
+ FORMAT_VL (name, sizeof (name), vl);
+ ERROR ("plugin_value_list_clone: Unable to determine "
+ "interval from context for "
+ "value list \"%s\". "
+ "This indicates a broken plugin. "
+ "Please report this problem to the "
+ "collectd mailing list or at "
+ "<http://collectd.org/bugs/>.", name);
+ vl->interval = cf_get_default_interval ();
+ }
+ }
+
return (vl);
} /* }}} value_list_t *plugin_value_list_clone */
return (-1);
}
- if (vl->time == 0)
- vl->time = cdtime ();
-
- if (vl->interval <= 0)
- {
- plugin_ctx_t ctx = plugin_get_ctx ();
-
- if (ctx.interval != 0)
- vl->interval = ctx.interval;
- else
- {
- char name[6 * DATA_MAX_NAME_LEN];
- FORMAT_VL (name, sizeof (name), vl);
- ERROR ("plugin_dispatch_values: Unable to determine "
- "interval from context for "
- "value list \"%s\". "
- "This indicates a broken plugin. "
- "Please report this problem to the "
- "collectd mailing list or at "
- "<http://collectd.org/bugs/>.", name);
- vl->interval = cf_get_default_interval ();
- }
- }
+ /* Assured by plugin_value_list_clone(). The write thread doesn't have
+ * access to the thread context, so the interval has to be filled in
+ * already. The time is determined at _enqueue_ time. */
+ assert (vl->time != 0);
+ assert (vl->interval != 0);
DEBUG ("plugin_dispatch_values: time = %.3f; interval = %.3f; "
"host = %s; "