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 #2660 from pbostley/master
[collectd.git]
/
src
/
write_graphite.c
diff --git
a/src/write_graphite.c
b/src/write_graphite.c
index
206cdc2
..
b39448f
100644
(file)
--- a/
src/write_graphite.c
+++ b/
src/write_graphite.c
@@
-156,11
+156,9
@@
static int wg_send_buffer(struct wg_callback *cb) {
status = swrite(cb->sock_fd, cb->send_buf, strlen(cb->send_buf));
if (status != 0) {
if (cb->log_send_errors) {
status = swrite(cb->sock_fd, cb->send_buf, strlen(cb->send_buf));
if (status != 0) {
if (cb->log_send_errors) {
- char errbuf[1024];
ERROR("write_graphite plugin: send to %s:%s (%s) failed with status %zi "
"(%s)",
ERROR("write_graphite plugin: send to %s:%s (%s) failed with status %zi "
"(%s)",
- cb->node, cb->service, cb->protocol, status,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ cb->node, cb->service, cb->protocol, status, STRERRNO);
}
close(cb->sock_fd);
}
close(cb->sock_fd);
@@
-177,7
+175,7
@@
static int wg_flush_nolock(cdtime_t timeout, struct wg_callback *cb) {
int status;
DEBUG("write_graphite plugin: wg_flush_nolock: timeout = %.3f; "
int status;
DEBUG("write_graphite plugin: wg_flush_nolock: timeout = %.3f; "
- "send_buf_fill = %
zu
;",
+ "send_buf_fill = %
" PRIsz "
;",
(double)timeout, cb->send_buf_fill);
/* timeout == 0 => flush unconditionally */
(double)timeout, cb->send_buf_fill);
/* timeout == 0 => flush unconditionally */
@@
-238,9
+236,7
@@
static int wg_callback_init(struct wg_callback *cb) {
cb->sock_fd =
socket(ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol);
if (cb->sock_fd < 0) {
cb->sock_fd =
socket(ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol);
if (cb->sock_fd < 0) {
- char errbuf[1024];
- snprintf(connerr, sizeof(connerr), "failed to open socket: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ snprintf(connerr, sizeof(connerr), "failed to open socket: %s", STRERRNO);
continue;
}
continue;
}
@@
-248,10
+244,8
@@
static int wg_callback_init(struct wg_callback *cb) {
status = connect(cb->sock_fd, ai_ptr->ai_addr, ai_ptr->ai_addrlen);
if (status != 0) {
status = connect(cb->sock_fd, ai_ptr->ai_addr, ai_ptr->ai_addrlen);
if (status != 0) {
- char errbuf[1024];
- snprintf(connerr, sizeof(connerr), "failed to connect to remote "
- "host: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ snprintf(connerr, sizeof(connerr), "failed to connect to remote host: %s",
+ STRERRNO);
close(cb->sock_fd);
cb->sock_fd = -1;
continue;
close(cb->sock_fd);
cb->sock_fd = -1;
continue;
@@
-263,9
+257,6
@@
static int wg_callback_init(struct wg_callback *cb) {
freeaddrinfo(ai_list);
if (cb->sock_fd < 0) {
freeaddrinfo(ai_list);
if (cb->sock_fd < 0) {
- if (connerr[0] == '\0')
- /* this should not happen but try to get a message anyway */
- sstrerror(errno, connerr, sizeof(connerr));
c_complain(LOG_ERR, &cb->init_complaint,
"write_graphite plugin: Connecting to %s:%s via %s failed. "
"The last error was: %s",
c_complain(LOG_ERR, &cb->init_complaint,
"write_graphite plugin: Connecting to %s:%s via %s failed. "
"The last error was: %s",
@@
-312,6
+303,7
@@
static void wg_callback_free(void *data) {
sfree(cb->prefix);
sfree(cb->postfix);
sfree(cb->prefix);
sfree(cb->postfix);
+ pthread_mutex_unlock(&cb->send_lock);
pthread_mutex_destroy(&cb->send_lock);
sfree(cb);
pthread_mutex_destroy(&cb->send_lock);
sfree(cb);
@@
-381,7
+373,8
@@
static int wg_send_message(char const *message, struct wg_callback *cb) {
cb->send_buf_fill += message_len;
cb->send_buf_free -= message_len;
cb->send_buf_fill += message_len;
cb->send_buf_free -= message_len;
- DEBUG("write_graphite plugin: [%s]:%s (%s) buf %zu/%zu (%.1f %%) \"%s\"",
+ DEBUG("write_graphite plugin: [%s]:%s (%s) buf %" PRIsz "/%" PRIsz
+ " (%.1f %%) \"%s\"",
cb->node, cb->service, cb->protocol, cb->send_buf_fill,
sizeof(cb->send_buf),
100.0 * ((double)cb->send_buf_fill) / ((double)sizeof(cb->send_buf)),
cb->node, cb->service, cb->protocol, cb->send_buf_fill,
sizeof(cb->send_buf),
100.0 * ((double)cb->send_buf_fill) / ((double)sizeof(cb->send_buf)),
@@
-545,11
+538,11
@@
static int wg_config_node(oconfig_item_t *ci) {
/* FIXME: Legacy configuration syntax. */
if (cb->name == NULL)
/* FIXME: Legacy configuration syntax. */
if (cb->name == NULL)
- s
s
nprintf(callback_name, sizeof(callback_name), "write_graphite/%s/%s/%s",
-
cb->node, cb->service, cb->protocol);
+ snprintf(callback_name, sizeof(callback_name), "write_graphite/%s/%s/%s",
+ cb->node, cb->service, cb->protocol);
else
else
- s
s
nprintf(callback_name, sizeof(callback_name), "write_graphite/%s",
-
cb->name);
+ snprintf(callback_name, sizeof(callback_name), "write_graphite/%s",
+ cb->name);
plugin_register_write(callback_name, wg_write,
&(user_data_t){
plugin_register_write(callback_name, wg_write,
&(user_data_t){