summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2cb5033)
raw | patch | inline | side by side (parent: 2cb5033)
author | Sebastian Harl <sh@tokkee.org> | |
Mon, 21 Jan 2013 15:35:17 +0000 (16:35 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Tue, 22 Jan 2013 09:31:47 +0000 (10:31 +0100) |
Else, the write plugins will have wrong or missing interval information when
actually writing a data-set.
Signed-off-by: Florian Forster <octo@collectd.org>
actually writing a data-set.
Signed-off-by: Florian Forster <octo@collectd.org>
src/plugin.c | patch | blob | history |
diff --git a/src/plugin.c b/src/plugin.c
index 409521b7141bf6890d4a69ff9054f1c4ea33da25..e7f8c6fd6566115837f144d38b04d79c51ed8fc5 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
struct write_queue_s
{
value_list_t *vl;
+ plugin_ctx_t ctx;
write_queue_t *next;
};
@@ -661,6 +662,15 @@ static value_list_t *plugin_value_list_clone (value_list_t const *vl_orig) /* {{
return (vl);
} /* }}} value_list_t *plugin_value_list_clone */
+static void plugin_write_queue_item_free (write_queue_t *q) /* {{{ */
+{
+ if (q == NULL)
+ return;
+
+ plugin_value_list_free (q->vl);
+ sfree (q);
+} /* }}} void plugin_write_queue_item_free */
+
static int plugin_write_enqueue (value_list_t const *vl) /* {{{ */
{
write_queue_t *q;
return (ENOMEM);
}
+ /* store context of caller (read plugin); else, the write plugins
+ * won't have the right interval settings available when actually
+ * dispatching the value-list later on */
+ q->ctx = plugin_get_ctx ();
+
pthread_mutex_lock (&write_lock);
if (write_queue_tail == NULL)
return (0);
} /* }}} int plugin_write_enqueue */
-static value_list_t *plugin_write_dequeue (void) /* {{{ */
+static write_queue_t *plugin_write_dequeue (void) /* {{{ */
{
write_queue_t *q;
- value_list_t *vl;
pthread_mutex_lock (&write_lock);
pthread_mutex_unlock (&write_lock);
- vl = q->vl;
- sfree (q);
- return (vl);
+ q->next = NULL;
+
+ return (q);
} /* }}} value_list_t *plugin_write_dequeue */
static void *plugin_write_thread (void __attribute__((unused)) *args) /* {{{ */
{
while (write_loop)
{
- value_list_t *vl = plugin_write_dequeue ();
- if (vl == NULL)
+ write_queue_t *q = plugin_write_dequeue ();
+ plugin_ctx_t old_ctx;
+
+ if (q == NULL)
continue;
- plugin_dispatch_values_internal (vl);
+ old_ctx = plugin_set_ctx (q->ctx);
- plugin_value_list_free (vl);
+ if (q->vl != NULL)
+ plugin_dispatch_values_internal (q->vl);
+
+ plugin_write_queue_item_free (q);
+ plugin_set_ctx (old_ctx);
}
pthread_exit (NULL);