proto: Fix FileIn ops that abort during the chunk upload stage.
authorRichard W.M. Jones <rjones@redhat.com>
Fri, 18 Mar 2011 17:17:30 +0000 (17:17 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Mon, 21 Mar 2011 11:34:43 +0000 (11:34 +0000)
commit821083b1c46005cfeebf384e81be812f6b0cc74b
treed0db37153f1260f38238cf385d7b0e77ebbb4f6c
parent1fba33e4ba3c0286b65167781fd48bb8b525a102
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.
12 files changed:
daemon/command.c
daemon/daemon.h
daemon/df.c
daemon/inotify.c
daemon/mount.c
daemon/tar.c
daemon/upload.c
generator/generator_daemon.ml
regressions/Makefile.am
regressions/rhbz576879.sh [moved from regressions/rhbz576879c0.sh with 94% similarity]
regressions/test-both-ends-cancel.sh [moved from regressions/rhbz576879c5.sh with 100% similarity]
regressions/test-upload-to-dir.sh [new file with mode: 0755]