From: Joel Rosdahl Date: Wed, 8 Jul 2020 07:54:50 +0000 (+0200) Subject: Remove short read optimization from #551 X-Git-Tag: v4.0~341 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4b71108612f7ed2c7d14738ff02f3783970f5ee4;p=thirdparty%2Fccache.git Remove short read optimization from #551 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. --- diff --git a/src/hash.cpp b/src/hash.cpp index 4d8ba65b4..1d7356af9 100644 --- a/src/hash.cpp +++ b/src/hash.cpp @@ -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(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; } diff --git a/src/hash.hpp b/src/hash.hpp index 5a104af5d..c5781fbe8 100644 --- a/src/hash.hpp +++ b/src/hash.hpp @@ -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. //