diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2011-03-18 17:17:30 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2011-03-21 11:34:43 +0000 |
commit | 821083b1c46005cfeebf384e81be812f6b0cc74b (patch) | |
tree | d0db37153f1260f38238cf385d7b0e77ebbb4f6c /daemon/daemon.h | |
parent | 1fba33e4ba3c0286b65167781fd48bb8b525a102 (diff) | |
download | libguestfs-821083b1c46005cfeebf384e81be812f6b0cc74b.tar.gz libguestfs-821083b1c46005cfeebf384e81be812f6b0cc74b.tar.xz libguestfs-821083b1c46005cfeebf384e81be812f6b0cc74b.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.
Cherry picked and rebased from
commit 33b638109ed66ea360b53b80b1f407b3a5f5ec39.
Diffstat (limited to 'daemon/daemon.h')
-rw-r--r-- | daemon/daemon.h | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/daemon/daemon.h b/daemon/daemon.h index 6845e1b3..86f13306 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -150,10 +150,6 @@ extern int receive_file (receive_cb cb, void *opaque); /* daemon functions that receive files (FileIn) can call this * to cancel incoming transfers (eg. if there is a local error). - * - * If and only if this function does NOT return -2, they MUST then - * call reply_with_* - * (see https://bugzilla.redhat.com/show_bug.cgi?id=576879#c5). */ extern int cancel_receive (void); @@ -179,8 +175,8 @@ extern void notify_progress (uint64_t position, uint64_t total); #define NEED_ROOT(cancel_stmt,fail_stmt) \ do { \ if (!root_mounted) { \ - if ((cancel_stmt) != -2) \ - reply_with_error ("%s: you must call 'mount' first to mount the root filesystem", __func__); \ + cancel_stmt; \ + reply_with_error ("%s: you must call 'mount' first to mount the root filesystem", __func__); \ fail_stmt; \ } \ } \ @@ -192,8 +188,8 @@ extern void notify_progress (uint64_t position, uint64_t total); #define ABS_PATH(path,cancel_stmt,fail_stmt) \ do { \ if ((path)[0] != '/') { \ - if ((cancel_stmt) != -2) \ - reply_with_error ("%s: path must start with a / character", __func__); \ + cancel_stmt; \ + reply_with_error ("%s: path must start with a / character", __func__); \ fail_stmt; \ } \ } while (0) @@ -208,18 +204,17 @@ extern void notify_progress (uint64_t position, uint64_t total); #define RESOLVE_DEVICE(path,cancel_stmt,fail_stmt) \ do { \ if (STRNEQLEN ((path), "/dev/", 5)) { \ - if ((cancel_stmt) != -2) \ - reply_with_error ("%s: %s: expecting a device name", __func__, (path)); \ + cancel_stmt; \ + reply_with_error ("%s: %s: expecting a device name", __func__, (path)); \ fail_stmt; \ } \ if (is_root_device (path)) \ reply_with_error ("%s: %s: device not found", __func__, path); \ if (device_name_translation ((path)) == -1) { \ int err = errno; \ - int r = cancel_stmt; \ + cancel_stmt; \ errno = err; \ - if (r != -2) \ - reply_with_perror ("%s: %s", __func__, path); \ + reply_with_perror ("%s: %s", __func__, path); \ fail_stmt; \ } \ } while (0) |