X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fwrite_riemann.c;h=00852ffbf2c851665196252ea45f2b445d8655f0;hb=4fdd7193481b638a059d6fa047542312e41ea45e;hp=10f89587b68c5d143bad251cb5ac89085dfccb6d;hpb=6159b6f81403b90eb2b1f1c60fa8006cd3405d1b;p=collectd.git diff --git a/src/write_riemann.c b/src/write_riemann.c index 10f89587..00852ffb 100644 --- a/src/write_riemann.c +++ b/src/write_riemann.c @@ -31,13 +31,11 @@ #include "collectd.h" #include "common.h" -#include "configfile.h" #include "plugin.h" #include "utils_cache.h" #include "utils_complain.h" #include "write_riemann_threshold.h" -#include #include #define RIEMANN_HOST "localhost" @@ -101,6 +99,7 @@ static int wrr_connect(struct riemann_host *host) /* {{{ */ node, port); return -1; } +#if RCC_VERSION_NUMBER >= 0x010800 if (host->timeout.tv_sec != 0) { if (riemann_client_set_timeout(host->client, &host->timeout) != 0) { riemann_client_free(host->client); @@ -111,6 +110,9 @@ static int wrr_connect(struct riemann_host *host) /* {{{ */ return -1; } } +#endif + + set_sock_opts(riemann_client_get_fd(host->client)); c_release(LOG_INFO, &host->init_complaint, "write_riemann plugin: Successfully connected to %s:%d", node, @@ -599,6 +601,7 @@ static void wrr_free(void *p) /* {{{ */ wrr_disconnect(host); + pthread_mutex_lock(&host->lock); pthread_mutex_destroy(&host->lock); sfree(host); } /* }}} void wrr_free */ @@ -610,7 +613,6 @@ static int wrr_config_node(oconfig_item_t *ci) /* {{{ */ int i; oconfig_item_t *child; char callback_name[DATA_MAX_NAME_LEN]; - user_data_t ud; if ((host = calloc(1, sizeof(*host))) == NULL) { ERROR("write_riemann plugin: calloc failed."); @@ -679,9 +681,14 @@ static int wrr_config_node(oconfig_item_t *ci) /* {{{ */ if (status != 0) break; } else if (strcasecmp("Timeout", child->key) == 0) { +#if RCC_VERSION_NUMBER >= 0x010800 status = cf_util_get_int(child, (int *)&host->timeout.tv_sec); if (status != 0) break; +#else + WARNING("write_riemann plugin: The Timeout option is not supported. " + "Please upgrade the Riemann client to at least 1.8.0."); +#endif } else if (strcasecmp("Port", child->key) == 0) { host->port = cf_util_get_port_number(child); if (host->port == -1) { @@ -788,8 +795,8 @@ static int wrr_config_node(oconfig_item_t *ci) /* {{{ */ ssnprintf(callback_name, sizeof(callback_name), "write_riemann/%s", host->name); - ud.data = host; - ud.free_func = wrr_free; + + user_data_t ud = {.data = host, .free_func = wrr_free}; pthread_mutex_lock(&host->lock);