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.4.1~4 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d9c851256eec5fa49821c6f1a7f3381c90850a71;p=collectd.git fix wg_send_buffer to reconnect tcp sockets on failure Conflicts: src/write_graphite.c --- 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;