netapp plugin: Added support for SnapVaultĀ® statistics.
[collectd.git] / src / plugin.c
index 409521b..7037234 100644 (file)
@@ -74,6 +74,7 @@ typedef struct write_queue_s write_queue_t;
 struct write_queue_s
 {
        value_list_t *vl;
+       plugin_ctx_t ctx;
        write_queue_t *next;
 };
 
@@ -632,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 ();
@@ -677,6 +674,11 @@ static int plugin_write_enqueue (value_list_t const *vl) /* {{{ */
                return (ENOMEM);
        }
 
+       /* 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);
 
        if (write_queue_tail == NULL)
@@ -719,6 +721,8 @@ static value_list_t *plugin_write_dequeue (void) /* {{{ */
 
        pthread_mutex_unlock (&write_lock);
 
+       (void) plugin_set_ctx (q->ctx);
+
        vl = q->vl;
        sfree (q);
        return (vl);
@@ -1807,9 +1811,8 @@ static int plugin_dispatch_values_internal (value_list_t *vl)
                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);