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>
Fri, 18 Mar 2011 17:56:45 +0000 (17:56 +0000)
commit33b638109ed66ea360b53b80b1f407b3a5f5ec39
treec1e04200129b5152428c089698642296b17421dc
parentc7368ce167d6dbfd3e69ba208301c5af3f17a8a1
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.
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]