summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c00b202)
raw | patch | inline | side by side (parent: c00b202)
author | Florian Forster <octo@collectd.org> | |
Tue, 22 Jan 2013 11:01:46 +0000 (12:01 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Tue, 22 Jan 2013 11:44:55 +0000 (12:44 +0100) |
The plugin_set_ctx() call has been moved into the plugin_write_dequeue()
function. Comments describing the unavailability of the context have
been updated.
function. Comments describing the unavailability of the context have
been updated.
src/plugin.c | patch | blob | history |
diff --git a/src/plugin.c b/src/plugin.c
index e7f8c6fd6566115837f144d38b04d79c51ed8fc5..70372342927c9fd2264cb70952fbd308d8317150 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -633,11 +633,7 @@ static value_list_t *plugin_value_list_clone (value_list_t const *vl_orig) /* {{
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. */
+ /* Fill in the interval from the thread context, if it is zero. */
if (vl->interval == 0)
{
plugin_ctx_t ctx = plugin_get_ctx ();
@@ -662,15 +658,6 @@ 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 */
+ /* Store context of caller (read plugin); otherwise, it would not be
+ * available to the write plugins when actually dispatching the
+ * value-list later on. */
q->ctx = plugin_get_ctx ();
pthread_mutex_lock (&write_lock);
return (0);
} /* }}} int plugin_write_enqueue */
-static write_queue_t *plugin_write_dequeue (void) /* {{{ */
+static value_list_t *plugin_write_dequeue (void) /* {{{ */
{
write_queue_t *q;
+ value_list_t *vl;
pthread_mutex_lock (&write_lock);
pthread_mutex_unlock (&write_lock);
- q->next = NULL;
+ (void) plugin_set_ctx (q->ctx);
- return (q);
+ vl = q->vl;
+ sfree (q);
+ return (vl);
} /* }}} value_list_t *plugin_write_dequeue */
static void *plugin_write_thread (void __attribute__((unused)) *args) /* {{{ */
{
while (write_loop)
{
- write_queue_t *q = plugin_write_dequeue ();
- plugin_ctx_t old_ctx;
-
- if (q == NULL)
+ value_list_t *vl = plugin_write_dequeue ();
+ if (vl == NULL)
continue;
- old_ctx = plugin_set_ctx (q->ctx);
+ plugin_dispatch_values_internal (vl);
- if (q->vl != NULL)
- plugin_dispatch_values_internal (q->vl);
-
- plugin_write_queue_item_free (q);
- plugin_set_ctx (old_ctx);
+ plugin_value_list_free (vl);
}
pthread_exit (NULL);
return (-1);
}
- /* 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. */
+ /* Assured by plugin_value_list_clone(). The time is determined at
+ * _enqueue_ time. */
assert (vl->time != 0);
assert (vl->interval != 0);