From 6e599567e02987014f10404a328b681492cad781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 10 Jan 2014 03:32:57 +0100 Subject: [PATCH] tar2qfile: retry if lseek() returns EAGAIN ... even though it shouldn't. Apparently it is happening. See #764 comments for details. --- qubes-rpc/tar2qfile.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/qubes-rpc/tar2qfile.c b/qubes-rpc/tar2qfile.c index 8f99546..4762a2b 100644 --- a/qubes-rpc/tar2qfile.c +++ b/qubes-rpc/tar2qfile.c @@ -916,15 +916,20 @@ 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 { - perror("lseek"); - exit(1); + 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