summaryrefslogtreecommitdiffstats
path: root/daemon/upload.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-03-18 17:17:30 +0000
committerRichard W.M. Jones <rjones@redhat.com>2011-03-18 17:56:45 +0000
commit33b638109ed66ea360b53b80b1f407b3a5f5ec39 (patch)
treec1e04200129b5152428c089698642296b17421dc /daemon/upload.c
parentc7368ce167d6dbfd3e69ba208301c5af3f17a8a1 (diff)
downloadlibguestfs-33b638109ed66ea360b53b80b1f407b3a5f5ec39.tar.gz
libguestfs-33b638109ed66ea360b53b80b1f407b3a5f5ec39.tar.xz
libguestfs-33b638109ed66ea360b53b80b1f407b3a5f5ec39.zip
proto: Fix FileIn ops that abort during the chunk upload stage.
As a previous, incorrect attempt to fix RHBZ#576879 we tried to prevent the daemon from sending an error reply if the daemon had cancelled the transfer. This is wrong: the daemon should send an error reply in these cases. A simple test case is this: guestfish -N fs -m /dev/sda1 upload big-file / (This fails because the target "/" is a directory, not a file.) Prior to this commit, libguestfs would hang instead of printing an error. With this commit, libguestfs prints an error. What is happening is: (1) Library is uploading a file (2) In the middle of the long upload, daemon detects an error. Daemon cancels. (3) Library detects cancel, sends cancel chunk, then waits for the error reply from the daemon. (4) Daemon is supposed to send an error reply message. Because step (4) wasn't happening, uploads that failed like this would hang in the library (waiting for the error message, while the daemon was waiting for the next request). This also adds a regression test. This temporarily breaks the "both ends cancel" case (RHBZ#576879c5). Therefore the test for that is disabled, and this is fixed in the next patch in the series. This partially reverts commit dc706a639eec16084c0618baf7bfde00c6565f63.
Diffstat (limited to 'daemon/upload.c')
-rw-r--r--daemon/upload.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/daemon/upload.c b/daemon/upload.c
index e28bf961..f8d312ff 100644
--- a/daemon/upload.c
+++ b/daemon/upload.c
@@ -70,7 +70,7 @@ upload (const char *filename, int flags, int64_t offset)
err = errno;
r = cancel_receive ();
errno = err;
- if (r != -2) reply_with_perror ("%s", filename);
+ reply_with_perror ("%s", filename);
return -1;
}
@@ -79,7 +79,7 @@ upload (const char *filename, int flags, int64_t offset)
err = errno;
r = cancel_receive ();
errno = err;
- if (r != -2) reply_with_perror ("lseek: %s", filename);
+ reply_with_perror ("lseek: %s", filename);
return -1;
}
}
@@ -89,7 +89,7 @@ upload (const char *filename, int flags, int64_t offset)
err = errno;
r = cancel_receive ();
errno = err;
- if (r != -2) reply_with_error ("write error: %s", filename);
+ reply_with_error ("write error: %s", filename);
close (data.fd);
return -1;
}
@@ -104,8 +104,7 @@ upload (const char *filename, int flags, int64_t offset)
if (r == -1) /* if r == 0, file transfer ended already */
r = cancel_receive ();
errno = err;
- if (r != -2)
- reply_with_perror ("close: %s", filename);
+ reply_with_perror ("close: %s", filename);
return -1;
}