mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
Fix tar-in command hangs when running out of disk space (RHBZ#580246).
The problem was this sequence of events: (1) File transfer goes through OK. (2) pclose returns failure (because 'tar' subprocess failed) (3) We try to cancel the transfer by calling cancel_receive. Step (3) fails because the transfer (as far as the library is concerned) has succeeded, so causing a hang. The more fundamental reason why we see steps (1) and (2) is that 'tar' does NOT fail immediately if there is a write error. Instead it continues reading and discarding the input until the end of the input before giving "Error exit delayed from previous errors". IMHO this is a bug with tar, since an ENOSPC write error should be fatal for tar.
This commit is contained in:
@@ -88,7 +88,8 @@ do_tar_in (const char *dir)
|
||||
|
||||
if (pclose (fp) != 0) {
|
||||
err = errno;
|
||||
cancel_receive ();
|
||||
if (r == -1) /* if r == 0, file transfer ended already */
|
||||
cancel_receive ();
|
||||
errno = err;
|
||||
reply_with_perror ("pclose: %s", dir);
|
||||
return -1;
|
||||
@@ -209,7 +210,8 @@ do_tgz_in (const char *dir)
|
||||
|
||||
if (pclose (fp) != 0) {
|
||||
err = errno;
|
||||
cancel_receive ();
|
||||
if (r == -1) /* if r == 0, file transfer ended already */
|
||||
cancel_receive ();
|
||||
errno = err;
|
||||
reply_with_perror ("pclose: %s", dir);
|
||||
return -1;
|
||||
|
||||
@@ -77,7 +77,8 @@ do_upload (const char *filename)
|
||||
|
||||
if (close (fd) == -1) {
|
||||
err = errno;
|
||||
cancel_receive ();
|
||||
if (r == -1) /* if r == 0, file transfer ended already */
|
||||
cancel_receive ();
|
||||
errno = err;
|
||||
reply_with_perror ("close: %s", filename);
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user