summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: badea20)
raw | patch | inline | side by side (parent: badea20)
author | Florian Forster <octo@collectd.org> | |
Thu, 22 Dec 2016 09:52:44 +0000 (10:52 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Thu, 22 Dec 2016 09:52:44 +0000 (10:52 +0100) |
src/daemon/common.c | patch | blob | history |
diff --git a/src/daemon/common.c b/src/daemon/common.c
index 0aa5345bd6643b8ba096a636a6b1d77bba80e368..1fa99eb245682114ea04e85457c4462121426b34 100644 (file)
--- a/src/daemon/common.c
+++ b/src/daemon/common.c
ptr = (const char *)buf;
nleft = count;
- if (fd < 0)
- return (-1);
+ if (fd < 0) {
+ errno = EINVAL;
+ return errno;
+ }
/* checking for closed peer connection */
pfd.fd = fd;
if (poll(&pfd, 1, 0) > 0) {
char buffer[32];
if (recv(fd, buffer, sizeof(buffer), MSG_PEEK | MSG_DONTWAIT) == 0) {
- // if recv returns zero (even though poll() said there is data to be
- // read),
- // that means the connection has been closed
- return -1;
+ /* if recv returns zero (even though poll() said there is data to be
+ * read), that means the connection has been closed */
+ return errno ? errno : -1;
}
}
continue;
if (status < 0)
- return (status);
+ return errno ? errno : status;
nleft = nleft - ((size_t)status);
ptr = ptr + ((size_t)status);