X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fzookeeper.c;h=9c70ea573f8f68988e1a350adeb45f4916c98193;hp=0b2507d88a47b4d2f11e0e32534a56eadf454bb1;hb=54619dc85fd308b21ed09a0271e5c7383c7921b9;hpb=c144ae4659e129a929afb67706a54604220fef43 diff --git a/src/zookeeper.c b/src/zookeeper.c index 0b2507d8..9c70ea57 100644 --- a/src/zookeeper.c +++ b/src/zookeeper.c @@ -26,8 +26,8 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" +#include "utils/common/common.h" #include #include @@ -37,8 +37,8 @@ #define ZOOKEEPER_DEF_HOST "127.0.0.1" #define ZOOKEEPER_DEF_PORT "2181" -static char *zk_host = NULL; -static char *zk_port = NULL; +static char *zk_host; +static char *zk_port; static const char *config_keys[] = {"Host", "Port"}; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); @@ -99,28 +99,22 @@ static int zookeeper_connect(void) { status = getaddrinfo(host, port, &ai_hints, &ai_list); if (status != 0) { - char errbuf[1024]; INFO("getaddrinfo failed: %s", - (status == EAI_SYSTEM) ? sstrerror(errno, errbuf, sizeof(errbuf)) - : gai_strerror(status)); + (status == EAI_SYSTEM) ? STRERRNO : gai_strerror(status)); return -1; } for (struct addrinfo *ai = ai_list; ai != NULL; ai = ai->ai_next) { sk = socket(ai->ai_family, SOCK_STREAM, 0); if (sk < 0) { - char errbuf[1024]; - WARNING("zookeeper: socket(2) failed: %s", - sstrerror(errno, errbuf, sizeof(errbuf))); + WARNING("zookeeper: socket(2) failed: %s", STRERRNO); continue; } status = (int)connect(sk, ai->ai_addr, ai->ai_addrlen); if (status != 0) { - char errbuf[1024]; close(sk); sk = -1; - WARNING("zookeeper: connect(2) failed: %s", - sstrerror(errno, errbuf, sizeof(errbuf))); + WARNING("zookeeper: connect(2) failed: %s", STRERRNO); continue; } @@ -144,9 +138,7 @@ static int zookeeper_query(char *buffer, size_t buffer_size) { status = (int)swrite(sk, "mntr\r\n", strlen("mntr\r\n")); if (status != 0) { - char errbuf[1024]; - ERROR("zookeeper: write(2) failed: %s", - sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("zookeeper: write(2) failed: %s", STRERRNO); close(sk); return -1; } @@ -158,11 +150,9 @@ static int zookeeper_query(char *buffer, size_t buffer_size) { buffer_size - buffer_fill, /* flags = */ 0)) != 0) { if (status < 0) { - char errbuf[1024]; if ((errno == EAGAIN) || (errno == EINTR)) continue; - ERROR("zookeeper: Error reading from socket: %s", - sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("zookeeper: Error reading from socket: %s", STRERRNO); close(sk); return -1; }