tar2qfile: retry if lseek() returns EAGAIN

... even though it shouldn't. Apparently it is happening. See #764
comments for details.
This commit is contained in:
Marek Marczykowski-Górecki 2014-01-10 03:32:57 +01:00
parent 1b9be23684
commit 6e599567e0

View File

@ -916,17 +916,22 @@ void tar_file_processor(int fd, struct filters *filters)
to_skip += BLKMULT-(to_skip%BLKMULT);
}
if (use_seek) {
ret = lseek(fd, to_skip, SEEK_CUR);
if (ret < 0) {
int tries = 3;
while (lseek(fd, to_skip, SEEK_CUR) < 0) {
if (errno == ESPIPE) {
// fallback to read()
use_seek = 0;
} else {
break;
} else if (errno == EAGAIN) {
/* WTF?! lseek theoretically never returns this error, but
* in practice it was seen... */
if (tries--)
continue;
}
perror("lseek");
exit(1);
}
}
}
// not using "else" because above can fallback to read() method
if (!use_seek) {
while (to_skip > 0) {