struct write_queue_s
{
value_list_t *vl;
+ plugin_ctx_t ctx;
write_queue_t *next;
};
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 ();
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)
pthread_mutex_unlock (&write_lock);
+ (void) plugin_set_ctx (q->ctx);
+
vl = q->vl;
sfree (q);
return (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);