projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #1454 from rubenk/libi2c-dev-mark-as-linux-only
[collectd.git]
/
src
/
write_riemann.c
diff --git
a/src/write_riemann.c
b/src/write_riemann.c
index
93bf853
..
5c59c92
100644
(file)
--- a/
src/write_riemann.c
+++ b/
src/write_riemann.c
@@
-33,7
+33,6
@@
#include "utils_cache.h"
#include "riemann.pb-c.h"
#include "utils_cache.h"
#include "riemann.pb-c.h"
-#include <sys/socket.h>
#include <arpa/inet.h>
#include <errno.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <errno.h>
#include <netdb.h>
@@
-365,7
+364,7
@@
static Msg *riemann_notification_to_protobuf(struct riemann_host *host, /* {{{ *
char service_buffer[6 * DATA_MAX_NAME_LEN];
char const *severity;
notification_meta_t *meta;
char service_buffer[6 * DATA_MAX_NAME_LEN];
char const *severity;
notification_meta_t *meta;
-
in
t i;
+
size_
t i;
msg = malloc (sizeof (*msg));
if (msg == NULL)
msg = malloc (sizeof (*msg));
if (msg == NULL)
@@
-474,7
+473,7
@@
static Event *riemann_value_to_protobuf(struct riemann_host const *host, /* {{{
char name_buffer[5 * DATA_MAX_NAME_LEN];
char service_buffer[6 * DATA_MAX_NAME_LEN];
double ttl;
char name_buffer[5 * DATA_MAX_NAME_LEN];
char service_buffer[6 * DATA_MAX_NAME_LEN];
double ttl;
-
in
t i;
+
size_
t i;
event = malloc (sizeof (*event));
if (event == NULL)
event = malloc (sizeof (*event));
if (event == NULL)
@@
-619,7
+618,7
@@
static Msg *riemann_value_list_to_protobuf (struct riemann_host const *host, /*
msg__init (msg);
/* Set up events. First, the list of pointers. */
msg__init (msg);
/* Set up events. First, the list of pointers. */
- msg->n_events =
(size_t)
vl->values_len;
+ msg->n_events = vl->values_len;
msg->events = calloc (msg->n_events, sizeof (*msg->events));
if (msg->events == NULL)
{
msg->events = calloc (msg->n_events, sizeof (*msg->events));
if (msg->events == NULL)
{
@@
-744,8
+743,8
@@
static int riemann_batch_add_value_list (struct riemann_host *host, /* {{{ */
len = msg__get_packed_size(host->batch_msg);
ret = 0;
len = msg__get_packed_size(host->batch_msg);
ret = 0;
- if (
len >= host->batch_max
) {
- ret = riemann_batch_flush_nolock(0, host);
+ if (
(host->batch_max < 0) || (((size_t) host->batch_max) <= len)
) {
+
ret = riemann_batch_flush_nolock(0, host);
}
pthread_mutex_unlock(&host->lock);
}
pthread_mutex_unlock(&host->lock);
@@
-789,6
+788,8
@@
static int riemann_write(const data_set_t *ds, /* {{{ */
status = write_riemann_threshold_check(ds, vl, statuses);
if (status != 0)
return status;
status = write_riemann_threshold_check(ds, vl, statuses);
if (status != 0)
return status;
+ } else {
+ memset (statuses, 0, sizeof (statuses));
}
if (host->use_tcp == 1 && host->batch_mode) {
}
if (host->use_tcp == 1 && host->batch_mode) {
@@
-1049,6
+1050,7
@@
static int riemann_config(oconfig_item_t *ci) /* {{{ */
}
if ((val = strdup(child->values[1].value.string)) == NULL) {
WARNING("cannot allocate memory for attribute value.");
}
if ((val = strdup(child->values[1].value.string)) == NULL) {
WARNING("cannot allocate memory for attribute value.");
+ sfree (key);
return (-1);
}
strarray_add(&riemann_attrs, &riemann_attrs_num, key);
return (-1);
}
strarray_add(&riemann_attrs, &riemann_attrs_num, key);