1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-18 10:35:55 +00:00

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
This commit is contained in:
Martin Matuska 2011-08-07 20:24:32 +00:00
parent 88c037e26a
commit b837506cbc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=224700
3 changed files with 27 additions and 16 deletions

View File

@ -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

View File

@ -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

View File

@ -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