]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Handle EINTR properly in Result::Writer::write_embedded_file_entry
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 19 Jul 2020 18:47:55 +0000 (20:47 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 19 Jul 2020 18:47:55 +0000 (20:47 +0200)
src/Result.cpp

index 375e911e264ff3f809f5e3d4d747ced68d200233..68e5771ae2f9abab9e434b85c5d9184d3e197ed0 100644 (file)
@@ -380,10 +380,14 @@ Result::Writer::write_embedded_file_entry(CacheEntryWriter& writer,
     uint8_t buf[READ_BUFFER_SIZE];
     size_t n = std::min(remain, static_cast<uint64_t>(sizeof(buf)));
     ssize_t bytes_read = read(*file, buf, n);
-    if (bytes_read < 1) {
+    if (bytes_read == -1) {
+      if (errno == EINTR) {
+        continue;
+      }
       throw Error(
         fmt::format("Error reading from {}: {}", path, strerror(errno)));
-    } else if (bytes_read == 0) {
+    }
+    if (bytes_read == 0) {
       throw Error(fmt::format("Error reading from {}: end of file", path));
     }
     writer.write(buf, n);