projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Run all changed files 68 8.c/1*.h through clang-format
[collectd.git]
/
src
/
zookeeper.c
diff --git
a/src/zookeeper.c
b/src/zookeeper.c
index
0b2507d
..
9c70ea5
100644
(file)
--- a/
src/zookeeper.c
+++ b/
src/zookeeper.c
@@
-26,8
+26,8
@@
#include "collectd.h"
#include "collectd.h"
-#include "common.h"
#include "plugin.h"
#include "plugin.h"
+#include "utils/common/common.h"
#include <netdb.h>
#include <netinet/in.h>
#include <netdb.h>
#include <netinet/in.h>
@@
-37,8
+37,8
@@
#define ZOOKEEPER_DEF_HOST "127.0.0.1"
#define ZOOKEEPER_DEF_PORT "2181"
#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);
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) {
status = getaddrinfo(host, port, &ai_hints, &ai_list);
if (status != 0) {
- char errbuf[1024];
INFO("getaddrinfo failed: %s",
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) {
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) {
continue;
}
status = (int)connect(sk, ai->ai_addr, ai->ai_addrlen);
if (status != 0) {
- char errbuf[1024];
close(sk);
sk = -1;
close(sk);
sk = -1;
- WARNING("zookeeper: connect(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("zookeeper: connect(2) failed: %s", STRERRNO);
continue;
}
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) {
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;
}
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) {
buffer_size - buffer_fill, /* flags = */ 0)) !=
0) {
if (status < 0) {
- char errbuf[1024];
if ((errno == EAGAIN) || (errno == EINTR))
continue;
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;
}
close(sk);
return -1;
}