]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
Properly report errors in readline() function
authorkwc@citi.umich.edu <kwc@citi.umich.edu>
Mon, 3 Jul 2006 22:34:38 +0000 (18:34 -0400)
committerNeil Brown <neilb@suse.de>
Tue, 4 Jul 2006 00:27:15 +0000 (10:27 +1000)
Signed-off-by: Kevin Coffman <kwc@citi.umich.edu>
Change message priorities for errors and debug messages.

utils/gssd/cacheio.c
utils/gssd/svcgssd_proc.c

index 07658e977a16685be7375e0a6f5ba9fbfb55da74..75c7a5d8e3b4a0d481d394db8a39257a4afe8bf3 100644 (file)
@@ -55,6 +55,7 @@
 #include <time.h>
 #include <stdlib.h>
 #include <string.h>
+#include <errno.h>
 #include "err_util.h"
 
 void qword_add(char **bpp, int *lp, char *str)
@@ -264,7 +265,8 @@ int readline(int fd, char **buf, int *lenp)
        }
        len = read(fd, *buf, *lenp);
        if (len <= 0) {
-               printerr(2, "read error in readline: %d\n", len);
+               printerr(0, "readline: read error: len %d errno %d (%s)\n",
+                        len, errno, strerror(errno));
                return 0;
        }
        while ((*buf)[len-1] != '\n') {
@@ -280,12 +282,14 @@ int readline(int fd, char **buf, int *lenp)
                *buf = new;
                nl = read(fd, *buf +len, *lenp - len);
                if (nl <= 0 ) {
-                       printerr(2, "read error in readline: %d\n", nl);
+                       printerr(0, "readline: read error: len %d "
+                                "errno %d (%s)\n", nl, errno, strerror(errno));
                        return 0;
                }
                len += nl;
        }
        (*buf)[len-1] = 0;
-       printerr(1, "read line with %d characters:\n%s\n", *lenp, *buf);
+       printerr(3, "readline: read %d chars into buffer of size %d:\n%s\n",
+                len, *lenp, *buf);
        return 1;
 }
index b3a6ae8cda53d351e2a236867094564e9df89b33..2251d9ab84a1feee03b7a4a8bd88f62262fbd157 100644 (file)
@@ -140,7 +140,7 @@ send_response(FILE *f, gss_buffer_desc *in_handle, gss_buffer_desc *in_token,
                return -1;
        }
        *bp = '\0';
-       printerr(1, "writing message: %s", buf);
+       printerr(3, "writing message: %s", buf);
        if (write(g, buf, bp - buf) == -1) {
                printerr(0, "WARNING: failed to write message\n");
                close(g);