diff options
author | mm <mm@FreeBSD.org> | 2011-08-07 20:24:32 +0000 |
---|---|---|
committer | mm <mm@FreeBSD.org> | 2011-08-07 20:24:32 +0000 |
commit | b6c6869e02cf5fedead9f1bfd7778d01c29ff498 (patch) | |
tree | af7e2b1b4da83c5030432974353c102671b73174 | |
parent | 3b8ed22952425642bc1493e6c65ae4d6e09a8438 (diff) | |
download | FreeBSD-src-b6c6869e02cf5fedead9f1bfd7778d01c29ff498.zip FreeBSD-src-b6c6869e02cf5fedead9f1bfd7778d01c29ff498.tar.gz |
Merge revision 3554 from libarchive's release/2.8 branch:
Partial merge of 2431 from trunk: Retry writes on EINTR.
This should fix the SIGINT handler in bsdtar.
Note: The rest of r2431 can't be merged, since it interacts
with a big write-side rearchitecture.
PR: bin/149409
Reviewed by: kientzle
Approved by: re (kib)
MFC after: 3 days
-rw-r--r-- | lib/libarchive/archive_write_open_fd.c | 15 | ||||
-rw-r--r-- | lib/libarchive/archive_write_open_file.c | 14 | ||||
-rw-r--r-- | lib/libarchive/archive_write_open_filename.c | 14 |
3 files changed, 27 insertions, 16 deletions
diff --git a/lib/libarchive/archive_write_open_fd.c b/lib/libarchive/archive_write_open_fd.c index b0793a2..1d27ce3 100644 --- a/lib/libarchive/archive_write_open_fd.c +++ b/lib/libarchive/archive_write_open_fd.c @@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$"); #include "archive.h" struct write_fd_data { - off_t offset; int fd; }; @@ -122,12 +121,16 @@ file_write(struct archive *a, void *client_data, const void *buff, size_t length ssize_t bytesWritten; mine = (struct write_fd_data *)client_data; - bytesWritten = write(mine->fd, buff, length); - if (bytesWritten <= 0) { - archive_set_error(a, errno, "Write error"); - return (-1); + for (;;) { + bytesWritten = write(mine->fd, buff, length); + if (bytesWritten <= 0) { + if (errno == EINTR) + continue; + archive_set_error(a, errno, "Write error"); + return (-1); + } + return (bytesWritten); } - return (bytesWritten); } static int diff --git a/lib/libarchive/archive_write_open_file.c b/lib/libarchive/archive_write_open_file.c index c99414f..68bf236 100644 --- a/lib/libarchive/archive_write_open_file.c +++ b/lib/libarchive/archive_write_open_file.c @@ -86,12 +86,16 @@ file_write(struct archive *a, void *client_data, const void *buff, size_t length size_t bytesWritten; mine = client_data; - bytesWritten = fwrite(buff, 1, length, mine->f); - if (bytesWritten < length) { - archive_set_error(a, errno, "Write error"); - return (-1); + for (;;) { + bytesWritten = fwrite(buff, 1, length, mine->f); + if (bytesWritten <= 0) { + if (errno == EINTR) + continue; + archive_set_error(a, errno, "Write error"); + return (-1); + } + return (bytesWritten); } - return (bytesWritten); } static int diff --git a/lib/libarchive/archive_write_open_filename.c b/lib/libarchive/archive_write_open_filename.c index 1db11f9..0c1e189 100644 --- a/lib/libarchive/archive_write_open_filename.c +++ b/lib/libarchive/archive_write_open_filename.c @@ -142,12 +142,16 @@ file_write(struct archive *a, void *client_data, const void *buff, size_t length ssize_t bytesWritten; mine = (struct write_file_data *)client_data; - bytesWritten = write(mine->fd, buff, length); - if (bytesWritten <= 0) { - archive_set_error(a, errno, "Write error"); - return (-1); + for (;;) { + bytesWritten = write(mine->fd, buff, length); + if (bytesWritten <= 0) { + if (errno == EINTR) + continue; + archive_set_error(a, errno, "Write error"); + return (-1); + } + return (bytesWritten); } - return (bytesWritten); } static int |