From: Michael Hart Date: Fri, 20 Dec 2013 14:56:54 +0000 (-0500) Subject: fix wg_send_buffer to reconnect tcp sockets on failure X-Git-Tag: collectd-5.5.0~327^2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=937c7cc7f9195b1579c7ebc198a9086eeec1a205;p=collectd.git fix wg_send_buffer to reconnect tcp sockets on failure --- 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;