Merge branch 'collectd-3.9'
[collectd.git] / src / common.c
index 138b767..5487b32 100644 (file)
@@ -144,6 +144,15 @@ ssize_t sread (int fd, void *buf, size_t count)
                if (status < 0)
                        return (status);
 
+               if (status == 0)
+               {
+                       DBG ("Received EOF from fd %i. "
+                                       "Closing fd and returning error.",
+                                       fd);
+                       close (fd);
+                       return (-1);
+               }
+
                assert (nleft >= status);
 
                nleft = nleft - status;
@@ -161,7 +170,7 @@ ssize_t swrite (int fd, const void *buf, size_t count)
        ssize_t     status;
 
        ptr   = (const char *) buf;
-       nleft = buflen;
+       nleft = count;
 
        while (nleft > 0)
        {