From d9c851256eec5fa49821c6f1a7f3381c90850a71 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 Conflicts: src/write_graphite.c --- 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 c3d6bf10..c17b7f36 100644 --- a/src/write_graphite.c +++ b/src/write_graphite.c @@ -128,15 +128,17 @@ 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]; const char *protocol = cb->protocol ? cb->protocol : WG_DEFAULT_PROTOCOL; - ERROR ("write_graphite plugin: send to %s:%s (%s) failed with status %zi (%s)", - cb->node, cb->service, 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, protocol, + status, sstrerror (errno, errbuf, sizeof (errbuf))); + } close (cb->sock_fd); cb->sock_fd = -1; -- 2.30.2