From: Florian Forster Date: Thu, 22 Dec 2016 09:57:57 +0000 (+0100) Subject: Merge branch 'collectd-5.7' X-Git-Tag: collectd-5.8.0~261 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=786a6be461cf58ef2b8c57974cad2a79ba2ee82c;hp=-c Merge branch 'collectd-5.7' --- 786a6be461cf58ef2b8c57974cad2a79ba2ee82c diff --combined src/daemon/common.c index 40822d0c,1fa99eb2..64dbee6f --- a/src/daemon/common.c +++ b/src/daemon/common.c @@@ -37,6 -37,10 +37,6 @@@ #include "plugin.h" #include "utils_cache.h" -#ifdef HAVE_MATH_H -#include -#endif - /* for getaddrinfo */ #include #include @@@ -267,8 -271,10 +267,10 @@@ ssize_t swrite(int fd, const void *buf ptr = (const char *)buf; nleft = count; - if (fd < 0) - return (-1); + if (fd < 0) { + errno = EINVAL; + return errno; + } /* checking for closed peer connection */ pfd.fd = fd; @@@ -277,10 -283,9 +279,9 @@@ if (poll(&pfd, 1, 0) > 0) { char buffer[32]; if (recv(fd, buffer, sizeof(buffer), MSG_PEEK | MSG_DONTWAIT) == 0) { - // if recv returns zero (even though poll() said there is data to be - // read), - // that means the connection has been closed - return -1; + /* if recv returns zero (even though poll() said there is data to be + * read), that means the connection has been closed */ + return errno ? errno : -1; } } @@@ -291,7 -296,7 +292,7 @@@ continue; if (status < 0) - return (status); + return errno ? errno : status; nleft = nleft - ((size_t)status); ptr = ptr + ((size_t)status); diff --combined src/daemon/configfile.c index b57aadc8,3934e1f9..654cc49b --- a/src/daemon/configfile.c +++ b/src/daemon/configfile.c @@@ -245,7 -245,7 +245,7 @@@ static int dispatch_value_plugindir(oco static int dispatch_loadplugin(oconfig_item_t *ci) { const char *name; - unsigned int flags = 0; + _Bool global = 0; plugin_ctx_t ctx = {0}; plugin_ctx_t old_ctx; int ret_val; @@@ -270,7 -270,7 +270,7 @@@ oconfig_item_t *child = ci->children + i; if (strcasecmp("Globals", child->key) == 0) - cf_util_get_flag(child, &flags, PLUGIN_FLAGS_GLOBAL); + cf_util_get_boolean(child, &global); else if (strcasecmp("Interval", child->key) == 0) cf_util_get_cdtime(child, &ctx.interval); else if (strcasecmp("FlushInterval", child->key) == 0) @@@ -285,7 -285,7 +285,7 @@@ } old_ctx = plugin_set_ctx(ctx); - ret_val = plugin_load(name, (uint32_t)flags); + ret_val = plugin_load(name, global); /* reset to the "global" context */ plugin_set_ctx(old_ctx); @@@ -1119,14 -1119,36 +1119,36 @@@ int cf_util_get_boolean(const oconfig_i if ((ci == NULL) || (ret_bool == NULL)) return (EINVAL); - if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) { + if ((ci->values_num != 1) || ((ci->values[0].type != OCONFIG_TYPE_BOOLEAN) && + (ci->values[0].type != OCONFIG_TYPE_STRING))) { ERROR("cf_util_get_boolean: The %s option requires " "exactly one boolean argument.", ci->key); return (-1); } - *ret_bool = ci->values[0].value.boolean ? 1 : 0; + switch (ci->values[0].type) { + case OCONFIG_TYPE_BOOLEAN: + *ret_bool = ci->values[0].value.boolean ? 1 : 0; + break; + case OCONFIG_TYPE_STRING: + WARNING("cf_util_get_boolean: Using string value `%s' for boolean option " + "`%s' is deprecated and will be removed in future releases. " + "Use unquoted true or false instead.", + ci->values[0].value.string, ci->key); + + if (IS_TRUE(ci->values[0].value.string)) + *ret_bool = 1; + else if (IS_FALSE(ci->values[0].value.string)) + *ret_bool = 0; + else { + ERROR("cf_util_get_boolean: Cannot parse string value `%s' of the `%s' " + "option as a boolean value.", + ci->values[0].value.string, ci->key); + return (-1); + } + break; + } return (0); } /* }}} int cf_util_get_boolean */ diff --combined src/netapp.c index 5b0827c9,45144bf1..13e1db92 --- a/src/netapp.c +++ b/src/netapp.c @@@ -674,7 -674,7 +674,7 @@@ static int submit_double(const char *ho const char *type, const char *type_inst, double d, cdtime_t timestamp, cdtime_t interval) { return (submit_values(host, plugin_inst, type, type_inst, - &(value_t){.gauge = counter}, 1, timestamp, interval)); + &(value_t){.gauge = d}, 1, timestamp, interval)); } /* }}} int submit_uint64 */ /* Calculate hit ratio from old and new counters and submit the resulting @@@ -1910,15 -1910,13 +1910,13 @@@ static int cna_query_quota(host_config_ static int cna_handle_snapvault_data(const char *hostname, /* {{{ */ cfg_snapvault_t *cfg_snapvault, na_elem_t *data, cdtime_t interval) { - na_elem_iter_t status_iter; - - status = na_elem_child(data, "status-list"); - if (!status) { + na_elem_t *status_list = na_elem_child(data, "status-list"); + if (status_list == NULL) { ERROR("netapp plugin: SnapVault status record missing status-list"); return (0); } - status_iter = na_child_iterator(status); + na_elem_iter_t status_iter = na_child_iterator(status_list); for (na_elem_t *status = na_iterator_next(&status_iter); status != NULL; status = na_iterator_next(&status_iter)) { const char *dest_sys, *dest_path, *src_sys, *src_path; @@@ -3111,3 -3109,5 +3109,3 @@@ void module_register(void) plugin_register_init("netapp", cna_init); plugin_register_shutdown("netapp", cna_shutdown); } - -/* vim: set sw=2 ts=2 noet fdm=marker : */