summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b44c855)
raw | patch | inline | side by side (parent: b44c855)
author | Florian Forster <octo@collectd.org> | |
Wed, 8 Feb 2012 15:38:01 +0000 (16:38 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 8 Feb 2012 15:38:01 +0000 (16:38 +0100) |
swrite() ensures that the entire buffer is written before the buffer is reset.
Change-Id: I105d42d8ea5b71acd5a5e37b7cc4209045f28d47
Change-Id: I105d42d8ea5b71acd5a5e37b7cc4209045f28d47
src/write_graphite.c | patch | blob | history |
diff --git a/src/write_graphite.c b/src/write_graphite.c
index 7a0bb12d43e6533388cecc1eb7700a4bf38571f9..de2266e85f96f281c0655b806ca2cb53da79ff21 100644 (file)
--- a/src/write_graphite.c
+++ b/src/write_graphite.c
static int wg_send_buffer (struct wg_callback *cb)
{
- int status = 0;
+ ssize_t status = 0;
- status = write (cb->sock_fd, cb->send_buf, strlen (cb->send_buf));
+ status = swrite (cb->sock_fd, cb->send_buf, strlen (cb->send_buf));
if (status < 0)
{
- ERROR ("write_graphite plugin: send failed with "
- "status %i (%s)",
- status,
- strerror (errno));
+ char errbuf[1024];
+ ERROR ("write_graphite plugin: send failed with status %zi (%s)",
+ status, sstrerror (errno, errbuf, sizeof (errbuf)));
+
close (cb->sock_fd);
cb->sock_fd = -1;
return (-1);
}
+
return (0);
}