From 937c7cc7f9195b1579c7ebc198a9086eeec1a205 Mon Sep 17 00:00:00 2001 From: Michael Hart Date: Fri, 20 Dec 2013 09:56:54 -0500 Subject: [PATCH] fix wg_send_buffer to reconnect tcp sockets on failure --- src/write_graphite.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/write_graphite.c b/src/write_graphite.c index 6124d33e..e49970c3 100644 --- a/src/write_graphite.c +++ b/src/write_graphite.c @@ -128,13 +128,15 @@ static int wg_send_buffer (struct wg_callback *cb) ssize_t status = 0; status = swrite (cb->sock_fd, cb->send_buf, strlen (cb->send_buf)); - if (cb->log_send_errors && status < 0) + if (status < 0) { - char errbuf[1024]; - 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))); - + if (cb->log_send_errors) + { + char errbuf[1024]; + 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))); + } close (cb->sock_fd); cb->sock_fd = -1; -- 2.30.2