author | Florian Forster <octo@collectd.org> | |
Thu, 18 May 2017 08:10:06 +0000 (10:10 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Thu, 18 May 2017 08:10:06 +0000 (10:10 +0200) |
1 | 2 | |||
---|---|---|---|---|
Makefile.am | patch | | diff1 | | diff2 | | blob | history |
README | patch | | diff1 | | diff2 | | blob | history |
configure.ac | patch | | diff1 | | diff2 | | blob | history |
src/collectd.conf.in | patch | | diff1 | | diff2 | | blob | history |
src/collectd.conf.pod | patch | | diff1 | | diff2 | | blob | history |
src/daemon/utils_avltree.c | patch | | diff1 | | diff2 | | blob | history |
src/daemon/utils_cache.c | patch | | diff1 | | diff2 | | blob | history |
diff --cc Makefile.am
Simple merge
diff --cc README
Simple merge
diff --cc configure.ac
Simple merge
diff --cc src/collectd.conf.in
Simple merge
diff --cc src/collectd.conf.pod
Simple merge
diff --cc src/daemon/utils_avltree.c
index 6a4e0f3e4dd8b523893f6a0ca80d682bed633df3,1cf3edfcfdc38eb26d597b2555be9a3b3356e062..87568fb243ffbed70e390f9a45dd402a41a03052
c_avl_node_t *n;
c_avl_node_t *p;
+ assert(t != NULL);
+
if ((key == NULL) || (value == NULL))
- return (-1);
+ return -1;
if (t->root == NULL)
- return (-1);
+ return -1;
n = t->root;
while ((n->left != NULL) || (n->right != NULL)) {
diff --cc src/daemon/utils_cache.c
index 5e111e6d06342792f1d90583c030099fca42005c,17118e066375a3e7854b20a69ce4ffc7c9f13b59..18aa66b74ad14c6b869b298992d3540c85a34e64
+++ b/src/daemon/utils_cache.c
"but uc_get_rate_by_name returned %zu.",
ds->type, ds->ds_num, ret_num);
sfree(ret);
- return (NULL);
+ return NULL;
}
- return (ret);
+ return ret;
} /* gauge_t *uc_get_rate */
+ int uc_get_value_by_name(const char *name, value_t **ret_values,
+ size_t *ret_values_num) {
+ value_t *ret = NULL;
+ size_t ret_num = 0;
+ cache_entry_t *ce = NULL;
+ int status = 0;
+
+ pthread_mutex_lock(&cache_lock);
+
+ if (c_avl_get(cache_tree, name, (void *) &ce) == 0) {
+ assert(ce != NULL);
+
+ /* remove missing values from getval */
+ if (ce->state == STATE_MISSING) {
+ status = -1;
+ } else {
+ ret_num = ce->values_num;
+ ret = malloc(ret_num * sizeof(*ret));
+ if (ret == NULL) {
+ ERROR("utils_cache: uc_get_value_by_name: malloc failed.");
+ status = -1;
+ } else {
+ memcpy(ret, ce->values_raw, ret_num * sizeof(value_t));
+ }
+ }
+ }
+ else {
+ DEBUG("utils_cache: uc_get_value_by_name: No such value: %s", name);
+ status = -1;
+ }
+
+ pthread_mutex_unlock(&cache_lock);
+
+ if (status == 0) {
+ *ret_values = ret;
+ *ret_values_num = ret_num;
+ }
+
+ return (status);
+ } /* int uc_get_value_by_name */
+
+ value_t *uc_get_value(const data_set_t *ds, const value_list_t *vl) {
+ char name[6 * DATA_MAX_NAME_LEN];
+ value_t *ret = NULL;
+ size_t ret_num = 0;
+ int status;
+
+ if (FORMAT_VL(name, sizeof(name), vl) != 0) {
+ ERROR("utils_cache: uc_get_value: FORMAT_VL failed.");
+ return (NULL);
+ }
+
+ status = uc_get_value_by_name(name, &ret, &ret_num);
+ if (status != 0)
+ return (NULL);
+
+ /* This is important - the caller has no other way of knowing how many
+ * values are returned. */
+ if (ret_num != (size_t) ds->ds_num) {
+ ERROR("utils_cache: uc_get_value: ds[%s] has %zu values, "
+ "but uc_get_value_by_name returned %zu.", ds->type, ds->ds_num,
+ ret_num);
+ sfree(ret);
+ return (NULL);
+ }
+
+ return (ret);
+ } /* value_t *uc_get_value */
+
size_t uc_get_size(void) {
size_t size_arrays = 0;