Fix compile time issues
[collectd.git] / src / write_tsdb.c
index 777f4cc..f8f4cb9 100644 (file)
@@ -43,8 +43,8 @@
 
 #include "collectd.h"
 
-#include "common.h"
 #include "plugin.h"
+#include "utils/common/common.h"
 #include "utils_cache.h"
 #include "utils_random.h"
 
@@ -79,8 +79,8 @@ struct wt_callback {
   char *service;
   char *host_tags;
 
-  _Bool store_rates;
-  _Bool always_append_ds;
+  bool store_rates;
+  bool always_append_ds;
 
   char send_buf[WT_SEND_BUF_SIZE];
   size_t send_buf_free;
@@ -89,13 +89,13 @@ struct wt_callback {
 
   pthread_mutex_t send_lock;
 
-  _Bool connect_failed_log_enabled;
+  bool connect_failed_log_enabled;
   int connect_dns_failed_attempts_remaining;
   cdtime_t next_random_ttl;
 };
 
-static cdtime_t resolve_interval = 0;
-static cdtime_t resolve_jitter = 0;
+static cdtime_t resolve_interval;
+static cdtime_t resolve_jitter;
 
 /*
  * Functions
@@ -112,9 +112,8 @@ static int wt_send_buffer(struct wt_callback *cb) {
 
   status = swrite(cb->sock_fd, cb->send_buf, strlen(cb->send_buf));
   if (status != 0) {
-    char errbuf[1024];
     ERROR("write_tsdb plugin: send failed with status %zi (%s)", status,
-          sstrerror(errno, errbuf, sizeof(errbuf)));
+          STRERRNO);
 
     close(cb->sock_fd);
     cb->sock_fd = -1;
@@ -153,7 +152,7 @@ static int wt_flush_nolock(cdtime_t timeout, struct wt_callback *cb) {
   return status;
 }
 
-static cdtime_t new_random_ttl() {
+static cdtime_t new_random_ttl(void) {
   if (resolve_jitter == 0)
     return 0;
 
@@ -242,10 +241,9 @@ static int wt_callback_init(struct wt_callback *cb) {
   }
 
   if (cb->sock_fd < 0) {
-    char errbuf[1024];
     ERROR("write_tsdb plugin: Connecting to %s:%s failed. "
           "The last error was: %s",
-          node, service, sstrerror(errno, errbuf, sizeof(errbuf)));
+          node, service, STRERRNO);
     return -1;
   }
 
@@ -279,6 +277,7 @@ static void wt_callback_free(void *data) {
   sfree(cb->service);
   sfree(cb->host_tags);
 
+  pthread_mutex_unlock(&cb->send_lock);
   pthread_mutex_destroy(&cb->send_lock);
 
   sfree(cb);
@@ -314,7 +313,7 @@ static int wt_flush(cdtime_t timeout,
 
 static int wt_format_values(char *ret, size_t ret_len, int ds_num,
                             const data_set_t *ds, const value_list_t *vl,
-                            _Bool store_rates) {
+                            bool store_rates) {
   size_t offset = 0;
   int status;
   gauge_t *rates = NULL;