projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
virt.c modifications to bring it in accordance with "octo" comments
[collectd.git]
/
src
/
zookeeper.c
diff --git
a/src/zookeeper.c
b/src/zookeeper.c
index
abdbf20
..
539112e
100644
(file)
--- a/
src/zookeeper.c
+++ b/
src/zookeeper.c
@@
-25,6
+25,7
@@
**/
#include "collectd.h"
**/
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
#include "common.h"
#include "plugin.h"
@@
-65,16
+66,12
@@
static int zookeeper_config(const char *key, const char *value)
return 0;
}
return 0;
}
-static void zookeeper_submit_gauge (const char * type, const char * type_inst, gauge_t val)
+static void zookeeper_submit_gauge (const char * type, const char * type_inst, gauge_t val
ue
)
{
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = val;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
vl.values_len = 1;
- sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "zookeeper", sizeof (vl.plugin));
sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
sstrncpy (vl.plugin, "zookeeper", sizeof (vl.plugin));
sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
@@
-83,16
+80,12
@@
static void zookeeper_submit_gauge (const char * type, const char * type_inst, g
plugin_dispatch_values (&vl);
} /* zookeeper_submit_gauge */
plugin_dispatch_values (&vl);
} /* zookeeper_submit_gauge */
-static void zookeeper_submit_derive (const char * type, const char * type_inst, derive_t val)
+static void zookeeper_submit_derive (const char * type, const char * type_inst, derive_t val
ue
)
{
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
value_list_t vl = VALUE_LIST_INIT;
- values[0].derive = val;
-
- vl.values = values;
+ vl.values = &(value_t) { .derive = value };
vl.values_len = 1;
vl.values_len = 1;
- sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "zookeeper", sizeof (vl.plugin));
sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
sstrncpy (vl.plugin, "zookeeper", sizeof (vl.plugin));
sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
@@
-105,18
+98,18
@@
static int zookeeper_connect (void)
{
int sk = -1;
int status;
{
int sk = -1;
int status;
- struct addrinfo ai_hints;
- struct addrinfo *ai;
struct addrinfo *ai_list;
struct addrinfo *ai_list;
- char *host;
- char *port;
-
- memset ((void *) &ai_hints, '\0', sizeof (ai_hints));
- ai_hints.ai_family = AF_UNSPEC;
- ai_hints.ai_socktype = SOCK_STREAM;
+ const char *host;
+ const char *port;
host = (zk_host != NULL) ? zk_host : ZOOKEEPER_DEF_HOST;
port = (zk_port != NULL) ? zk_port : ZOOKEEPER_DEF_PORT;
host = (zk_host != NULL) ? zk_host : ZOOKEEPER_DEF_HOST;
port = (zk_port != NULL) ? zk_port : ZOOKEEPER_DEF_PORT;
+
+ struct addrinfo ai_hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_socktype = SOCK_STREAM
+ };
+
status = getaddrinfo (host, port, &ai_hints, &ai_list);
if (status != 0)
{
status = getaddrinfo (host, port, &ai_hints, &ai_list);
if (status != 0)
{
@@
-128,7
+121,7
@@
static int zookeeper_connect (void)
return (-1);
}
return (-1);
}
- for (ai = ai_list; ai != NULL; ai = ai->ai_next)
+ for (
struct addrinfo *
ai = ai_list; ai != NULL; ai = ai->ai_next)
{
sk = socket (ai->ai_family, SOCK_STREAM, 0);
if (sk < 0)
{
sk = socket (ai->ai_family, SOCK_STREAM, 0);
if (sk < 0)
@@
-159,8
+152,7
@@
static int zookeeper_connect (void)
static int zookeeper_query (char *buffer, size_t buffer_size)
{
static int zookeeper_query (char *buffer, size_t buffer_size)
{
- int sk = -1;
- int status;
+ int sk, status;
size_t buffer_fill;
sk = zookeeper_connect();
size_t buffer_fill;
sk = zookeeper_connect();
@@
-198,11
+190,6
@@
static int zookeeper_query (char *buffer, size_t buffer_size)
}
buffer_fill += (size_t) status;
}
buffer_fill += (size_t) status;
- if (status == 0)
- {
- /* done reading from the socket */
- break;
- }
} /* while (recv) */
status = 0;
} /* while (recv) */
status = 0;