Code

utils unixsock: Fixed EOF handling in recv().
authorSebastian Harl <sh@tokkee.org>
Tue, 11 Dec 2012 08:06:57 +0000 (09:06 +0100)
committerSebastian Harl <sh@tokkee.org>
Tue, 11 Dec 2012 08:06:57 +0000 (09:06 +0100)
src/utils/unixsock.c

index 1be17b9994600878024a8f3b9a4c1a15d1e96eb4..70fd273679bf170f7fd40fd29d2e4417f142beb3 100644 (file)
@@ -144,10 +144,12 @@ sc_unixsock_client_recv(sc_unixsock_client_t *client, char *buffer, size_t bufle
                return NULL;
 
        buffer = fgets(buffer, (int)buflen - 1, client->fh);
-       if ((! buffer) && (! feof(client->fh))) {
-               char errbuf[1024];
-               fprintf(stderr, "unixsock: Failed to read from socket (%s): %s\n",
-                               client->path, sc_strerror(errno, errbuf, sizeof(errbuf)));
+       if (! buffer) {
+               if (! feof(client->fh)) {
+                       char errbuf[1024];
+                       fprintf(stderr, "unixsock: Failed to read from socket (%s): %s\n",
+                                       client->path, sc_strerror(errno, errbuf, sizeof(errbuf)));
+               }
                return buffer;
        }
        buffer[buflen - 1] = '\0';