summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d462e60)
raw | patch | inline | side by side (parent: d462e60)
author | Florian Forster <octo@collectd.org> | |
Wed, 21 Sep 2016 09:32:20 +0000 (11:32 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 21 Sep 2016 09:32:20 +0000 (11:32 +0200) |
A copy of the values was made in plugin_dispatch_values_internal(). This
code predates the "write queue", which means that each value list (and
its values) are copied anyway and vl->values will always point to heap
memory.
code predates the "write queue", which means that each value list (and
its values) are copied anyway and vl->values will always point to heap
memory.
src/daemon/plugin.c | patch | blob | history |
diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c
index d9f8da8c04a2270a0bdff44537ec2dcc0e55e2f5..50ab67573c7504148877f09955c2cf8c8ff03c5d 100644 (file)
--- a/src/daemon/plugin.c
+++ b/src/daemon/plugin.c
int status;
static c_complain_t no_write_complaint = C_COMPLAIN_INIT_STATIC;
- value_t *saved_values;
- int saved_values_len;
-
data_set_t *ds;
_Bool free_meta_data = 0;
escape_slashes (vl->type, sizeof (vl->type));
escape_slashes (vl->type_instance, sizeof (vl->type_instance));
- /* Copy the values. This way, we can assure `targets' that they get
- * dynamically allocated values, which they can free and replace if
- * they like. */
- if ((pre_cache_chain != NULL) || (post_cache_chain != NULL))
- {
- saved_values = vl->values;
- saved_values_len = vl->values_len;
-
- vl->values = (value_t *) calloc (vl->values_len,
- sizeof (*vl->values));
- if (vl->values == NULL)
- {
- ERROR ("plugin_dispatch_values: calloc failed.");
- vl->values = saved_values;
- return (-1);
- }
- memcpy (vl->values, saved_values,
- vl->values_len * sizeof (*vl->values));
- }
- else /* if ((pre == NULL) && (post == NULL)) */
- {
- saved_values = NULL;
- saved_values_len = 0;
- }
-
if (pre_cache_chain != NULL)
{
status = fc_process_chain (ds, vl, pre_cache_chain);
status, status);
}
else if (status == FC_TARGET_STOP)
- {
- /* Restore the state of the value_list so that plugins
- * don't get confused.. */
- if (saved_values != NULL)
- {
- sfree (vl->values);
- vl->values = saved_values;
- vl->values_len = saved_values_len;
- }
return (0);
- }
}
/* Update the value cache */
else
fc_default_action (ds, vl);
- /* Restore the state of the value_list so that plugins don't get
- * confused.. */
- if (saved_values != NULL)
- {
- sfree (vl->values);
- vl->values = saved_values;
- vl->values_len = saved_values_len;
- }
-
if ((free_meta_data != 0) && (vl->meta != NULL))
{
meta_data_destroy (vl->meta);