X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fupload.c;h=dffe41190bd7c02f665b3d1b8e6c3a2c64325717;hb=bcd2dba76efa4da4edb1b04f6348b0a0dfb109c2;hp=e28bf961c78add1cd5f47f6d2ee7c83c47bf3cf0;hpb=8022d46e5e2d9c3ab664ace6c9f185976e34dc20;p=libguestfs.git diff --git a/daemon/upload.c b/daemon/upload.c index e28bf96..dffe411 100644 --- a/daemon/upload.c +++ b/daemon/upload.c @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include @@ -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,23 +89,21 @@ 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; } if (r == -2) { /* cancellation from library */ + /* This error is ignored by the library since it initiated the + * cancel. Nevertheless we must send an error reply here. + */ + reply_with_error ("file upload cancelled"); close (data.fd); - /* Do NOT send any error. */ return -1; } if (close (data.fd) == -1) { - err = errno; - 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; }