X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fgmond.c;h=2bca05adc0235ec758db3f5e30e4966f499dbe37;hb=74ee9a04ef5785b31d1acbfdcbcece3370668cfe;hp=6ed4115da8e241b6f91e0a4686133baa4fab00df;hpb=a396da422740caf336a6d594515e8d80de6f440a;p=collectd.git diff --git a/src/gmond.c b/src/gmond.c index 6ed4115d..2bca05ad 100644 --- a/src/gmond.c +++ b/src/gmond.c @@ -89,14 +89,14 @@ static char *mc_receive_group; static char *mc_receive_port; static struct pollfd *mc_receive_sockets; -static size_t mc_receive_sockets_num = 0; +static size_t mc_receive_sockets_num; static socket_entry_t *mc_send_sockets; -static size_t mc_send_sockets_num = 0; +static size_t mc_send_sockets_num; static pthread_mutex_t mc_send_sockets_lock = PTHREAD_MUTEX_INITIALIZER; -static int mc_receive_thread_loop = 0; -static int mc_receive_thread_running = 0; +static int mc_receive_thread_loop; +static int mc_receive_thread_running; static pthread_t mc_receive_thread_id; static metric_map_t metric_map_default[] = @@ -123,7 +123,7 @@ static metric_map_t metric_map_default[] = static size_t metric_map_len_default = STATIC_ARRAY_SIZE(metric_map_default); static metric_map_t *metric_map; -static size_t metric_map_len = 0; +static size_t metric_map_len; static c_avl_tree_t *staging_tree; static pthread_mutex_t staging_lock = PTHREAD_MUTEX_INITIALIZER; @@ -833,28 +833,6 @@ static int mc_receive_thread_stop(void) /* {{{ */ * * */ -static int gmond_config_set_string(oconfig_item_t *ci, char **str) /* {{{ */ -{ - char *tmp; - - if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) { - WARNING("gmond plugin: The `%s' option needs " - "exactly one string argument.", - ci->key); - return -1; - } - - tmp = strdup(ci->values[0].value.string); - if (tmp == NULL) { - ERROR("gmond plugin: strdup failed."); - return -1; - } - - sfree(*str); - *str = tmp; - return 0; -} /* }}} int gmond_config_set_string */ - static int gmond_config_add_metric(oconfig_item_t *ci) /* {{{ */ { metric_map_t *map; @@ -889,11 +867,11 @@ static int gmond_config_add_metric(oconfig_item_t *ci) /* {{{ */ for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp("Type", child->key) == 0) - gmond_config_set_string(child, &map->type); + cf_util_get_string(child, &map->type); else if (strcasecmp("TypeInstance", child->key) == 0) - gmond_config_set_string(child, &map->type_instance); + cf_util_get_string(child, &map->type_instance); else if (strcasecmp("DataSource", child->key) == 0) - gmond_config_set_string(child, &map->ds_name); + cf_util_get_string(child, &map->ds_name); else { WARNING("gmond plugin: Unknown configuration option `%s' ignored.", child->key);