X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=src%2Fguestfs.c;h=74fd76b06d0a19357c606d791f6b606b237e7b61;hb=e44128bf547024509bc064e728fb269504486659;hp=1b7d61ca96bea0bedf088f6491188f43b09a6788;hpb=170f262f0413de843af62b968f6d12c1c476ae7f;p=libguestfs.git diff --git a/src/guestfs.c b/src/guestfs.c index 1b7d61c..74fd76b 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -1534,11 +1534,14 @@ guestfs__send_file_sync (guestfs_h *g, const char *filename) /* Send file in chunked encoding. */ while (!cancel && (r = read (fd, buf, sizeof buf)) > 0) { err = send_file_data_sync (g, buf, r); - if (err < 0) + if (err < 0) { + if (err == -2) /* daemon sent cancellation */ + send_file_cancellation_sync (g); return err; + } } - if (cancel) { + if (cancel) { /* cancel from either end */ send_file_cancellation_sync (g); return -1; } @@ -1604,14 +1607,22 @@ send_file_chunk_sync (guestfs_h *g, int cancel, const char *buf, size_t len) } /* Did the daemon send a cancellation message? */ - if (check_for_daemon_cancellation (g)) + if (check_for_daemon_cancellation (g)) { + if (g->verbose) + fprintf (stderr, "got daemon cancellation\n"); return -2; + } /* Serialize the chunk. */ chunk.cancel = cancel; chunk.data.data_len = len; chunk.data.data_val = (char *) buf; + if (g->verbose) + fprintf (stderr, + "library sending chunk cancel = %d, len = %zu, buf = %p\n", + cancel, len, buf); + xdrmem_create (&xdr, data, sizeof data, XDR_ENCODE); if (!xdr_guestfs_chunk (&xdr, &chunk)) { error (g, "xdr_guestfs_chunk failed (buf = %p, len = %zu)", buf, len);