Merge remote-tracking branch 'github/pr/2388'
[collectd.git] / src / daemon / common.c
index 31daa37..6c856a6 100644 (file)
@@ -180,8 +180,8 @@ char *sstrerror(int errnum, char *buf, size_t buflen) {
 #else
   if (strerror_r(errnum, buf, buflen) != 0) {
     snprintf(buf, buflen, "Error #%i; "
-                           "Additionally, strerror_r failed.",
-              errnum);
+                          "Additionally, strerror_r failed.",
+             errnum);
   }
 #endif /* STRERROR_R_CHAR_P */
 
@@ -269,7 +269,8 @@ ssize_t swrite(int fd, const void *buf, size_t count) {
     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 errno ? errno : -1;
+      errno = ECONNRESET;
+      return -1;
     }
   }