mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
Retry reads that fail with EINTR. This fixes a problem
with bsdtar failing on SIGINT.
This commit is contained in:
parent
1dfdc15bb0
commit
50e63ee142
2 changed files with 20 additions and 12 deletions
|
|
@ -116,11 +116,15 @@ file_read(struct archive *a, void *client_data, const void **buff)
|
|||
ssize_t bytes_read;
|
||||
|
||||
*buff = mine->buffer;
|
||||
bytes_read = read(mine->fd, mine->buffer, mine->block_size);
|
||||
if (bytes_read < 0) {
|
||||
archive_set_error(a, errno, "Error reading fd %d", mine->fd);
|
||||
for (;;) {
|
||||
bytes_read = read(mine->fd, mine->buffer, mine->block_size);
|
||||
if (bytes_read < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
archive_set_error(a, errno, "Error reading fd %d", mine->fd);
|
||||
}
|
||||
return (bytes_read);
|
||||
}
|
||||
return (bytes_read);
|
||||
}
|
||||
|
||||
#if ARCHIVE_API_VERSION < 2
|
||||
|
|
|
|||
|
|
@ -160,15 +160,19 @@ file_read(struct archive *a, void *client_data, const void **buff)
|
|||
ssize_t bytes_read;
|
||||
|
||||
*buff = mine->buffer;
|
||||
bytes_read = read(mine->fd, mine->buffer, mine->block_size);
|
||||
if (bytes_read < 0) {
|
||||
if (mine->filename[0] == '\0')
|
||||
archive_set_error(a, errno, "Error reading stdin");
|
||||
else
|
||||
archive_set_error(a, errno, "Error reading '%s'",
|
||||
mine->filename);
|
||||
for (;;) {
|
||||
bytes_read = read(mine->fd, mine->buffer, mine->block_size);
|
||||
if (bytes_read < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
else if (mine->filename[0] == '\0')
|
||||
archive_set_error(a, errno, "Error reading stdin");
|
||||
else
|
||||
archive_set_error(a, errno, "Error reading '%s'",
|
||||
mine->filename);
|
||||
}
|
||||
return (bytes_read);
|
||||
}
|
||||
return (bytes_read);
|
||||
}
|
||||
|
||||
#if ARCHIVE_API_VERSION < 2
|
||||
|
|
|
|||
Loading…
Reference in a new issue