recv_pattern(): Improve error diagnostics.
authorAndre Noll <maan@systemlinux.org>
Sun, 20 Dec 2009 18:46:05 +0000 (19:46 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 20 Dec 2009 18:46:05 +0000 (19:46 +0100)
It is good to know the string that was received, or the reason why nothing was
received.

net.c

diff --git a/net.c b/net.c
index 61f50dd..00844d7 100644 (file)
--- a/net.c
+++ b/net.c
@@ -838,10 +838,11 @@ int recv_pattern(int fd, const char *pattern, size_t bufsize)
        ret = 1;
 out:
        if (ret < 0) {
-               PARA_NOTICE_LOG("n = %d, did not receive pattern '%s'\n", n,
-                       pattern);
+               PARA_NOTICE_LOG("did not receive pattern '%s'\n", pattern);
                if (n > 0)
-                       PARA_NOTICE_LOG("recvd: %s\n", buf);
+                       PARA_NOTICE_LOG("recvd %d bytes: %s\n", n, buf);
+               else if (n < 0)
+                       PARA_NOTICE_LOG("%s\n", para_strerror(-n));
        }
        free(buf);
        return ret;