]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Remove short read optimization from #551
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 8 Jul 2020 07:54:50 +0000 (09:54 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 8 Jul 2020 08:01:05 +0000 (10:01 +0200)
I don’t feel confident about assuming that a short read for a file means
EOF in all situations. For instance, it looks like short reads can
happen of an NFS file system mounted with the “intr” option, and it can
also happen if a file entry actually is a named pipe.

src/hash.cpp
src/hash.hpp

index 4d8ba65b4e585f4ce9eca9c7649ae168a4a138bc..1d7356af971af74619303123be15995a7655f37b 100644 (file)
@@ -169,7 +169,7 @@ hash_int(struct hash* hash, int x)
 }
 
 bool
-hash_fd(struct hash* hash, int fd, bool fd_is_file)
+hash_fd(struct hash* hash, int fd)
 {
   char buf[READ_BUFFER_SIZE];
   ssize_t n;
@@ -181,9 +181,6 @@ hash_fd(struct hash* hash, int fd, bool fd_is_file)
     if (n > 0) {
       do_hash_buffer(hash, buf, n);
       do_debug_text(hash, buf, n);
-      if (fd_is_file && static_cast<size_t>(n) < sizeof(buf)) {
-        break;
-      }
     }
   }
   return n >= 0;
@@ -198,6 +195,6 @@ hash_file(struct hash* hash, const char* fname)
     return false;
   }
 
-  bool ret = hash_fd(hash, *fd, true);
+  bool ret = hash_fd(hash, *fd);
   return ret;
 }
index 5a104af5d0e74915b884f49be60930520a06a646..c5781fbe8a97f6592f0fbcf4537934594ad17602 100644 (file)
@@ -92,7 +92,7 @@ void hash_int(struct hash* hash, int x);
 // file.
 //
 // Returns true on success, otherwise false.
-bool hash_fd(struct hash* hash, int fd, bool fd_is_file = false);
+bool hash_fd(struct hash* hash, int fd);
 
 // Add contents of a file to the hash.
 //