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); to_skip += BLKMULT-(to_skip%BLKMULT);
} }
if (use_seek) { if (use_seek) {
ret = lseek(fd, to_skip, SEEK_CUR); int tries = 3;
if (ret < 0) { while (lseek(fd, to_skip, SEEK_CUR) < 0) {
if (errno == ESPIPE) { if (errno == ESPIPE) {
// fallback to read() // fallback to read()
use_seek = 0; 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"); perror("lseek");
exit(1); exit(1);
} }
} }
}
// not using "else" because above can fallback to read() method // not using "else" because above can fallback to read() method
if (!use_seek) { if (!use_seek) {
while (to_skip > 0) { while (to_skip > 0) {