diff options
author | Richard Jones <rjones@trick.home.annexia.org> | 2009-09-17 15:28:41 +0100 |
---|---|---|
committer | Richard Jones <rjones@trick.home.annexia.org> | 2009-09-17 16:05:39 +0100 |
commit | abac360f324d8c881878c5d9b7fb64be93981125 (patch) | |
tree | 78f3b482e8df08c7c4065df1b668eee91a033b83 /daemon/proto.c | |
parent | bb02f0fbe80ef093731bc9a6a407f1edaccf991d (diff) | |
download | libguestfs-abac360f324d8c881878c5d9b7fb64be93981125.tar.gz libguestfs-abac360f324d8c881878c5d9b7fb64be93981125.tar.xz libguestfs-abac360f324d8c881878c5d9b7fb64be93981125.zip |
Daemon: fix handling of errors from xread and xwrite.
If xread or xwrite returns -1, that indicates an error and we
should exit. Note that xread/xwrite has already printed the
error message.
Diffstat (limited to 'daemon/proto.c')
-rw-r--r-- | daemon/proto.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/daemon/proto.c b/daemon/proto.c index d03a048c..c0e39275 100644 --- a/daemon/proto.c +++ b/daemon/proto.c @@ -62,7 +62,9 @@ main_loop (int _sock) #endif /* Read the length word. */ - xread (sock, lenbuf, 4); + if (xread (sock, lenbuf, 4) == -1) + exit (1); + xdrmem_create (&xdr, lenbuf, 4, XDR_DECODE); xdr_uint32_t (&xdr, &len); xdr_destroy (&xdr); @@ -79,7 +81,8 @@ main_loop (int _sock) continue; } - xread (sock, buf, len); + if (xread (sock, buf, len) == -1) + exit (1); #ifdef ENABLE_PACKET_DUMP if (verbose) { @@ -307,7 +310,9 @@ receive_file (receive_cb cb, void *opaque) for (;;) { /* Read the length word. */ - xread (sock, lenbuf, 4); + if (xread (sock, lenbuf, 4) == -1) + exit (1); + xdrmem_create (&xdr, lenbuf, 4, XDR_DECODE); xdr_uint32_t (&xdr, &len); xdr_destroy (&xdr); @@ -327,7 +332,8 @@ receive_file (receive_cb cb, void *opaque) return -1; } - xread (sock, buf, len); + if (xread (sock, buf, len) == -1) + exit (1); xdrmem_create (&xdr, buf, len, XDR_DECODE); memset (&chunk, 0, sizeof chunk); @@ -444,10 +450,8 @@ check_for_library_cancellation (void) /* Read the message from the daemon. */ r = xread (sock, buf, sizeof buf); - if (r == -1) { - perror ("read"); + if (r == -1) return 0; - } xdrmem_create (&xdr, buf, sizeof buf, XDR_DECODE); xdr_uint32_t (&xdr, &flag); |