From: Joel Rosdahl Date: Wed, 2 Mar 2016 19:57:08 +0000 (+0100) Subject: Handle some more "stale NFS file handle" cases X-Git-Tag: v3.2.5~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1fffcd04441a598683e45d649756a7105c9a2bbc;p=thirdparty%2Fccache.git Handle some more "stale NFS file handle" cases --- diff --git a/NEWS.txt b/NEWS.txt index 94cf42759..ad6f30e2f 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -10,6 +10,8 @@ New features and improvements - Only pass clang-specific `-stdlib=` to the preprocessor. +- Improved handling of stale NFS handles. + Bug fixes ~~~~~~~~~ diff --git a/ccache.c b/ccache.c index 58e60a0c4..5ec529946 100644 --- a/ccache.c +++ b/ccache.c @@ -843,7 +843,7 @@ get_file_from_cache(const char *source, const char *dest) } if (ret == -1) { - if (errno == ENOENT) { + if (errno == ENOENT || errno == ESTALE) { /* Someone removed the file just before we began copying? */ cc_log("Cache file %s just disappeared from cache", source); stats_update(STATS_MISSING); diff --git a/cleanup.c b/cleanup.c index 6eadaa443..dcb1a1570 100644 --- a/cleanup.c +++ b/cleanup.c @@ -108,7 +108,7 @@ delete_file(const char *path, size_t size) if (x_unlink(path) == 0) { cache_size -= size; files_in_cache--; - } else if (errno != ENOENT) { + } else if (errno != ENOENT && errno != ESTALE) { cc_log("Failed to unlink %s (%s)", path, strerror(errno)); } } @@ -122,7 +122,7 @@ delete_sibling_file(const char *base, const char *extension) path = format("%s%s", base, extension); if (lstat(path, &st) == 0) { delete_file(path, file_size(&st)); - } else if (errno != ENOENT) { + } else if (errno != ENOENT && errno != ESTALE) { cc_log("Failed to stat %s: %s", path, strerror(errno)); } free(path); diff --git a/util.c b/util.c index 0b78afffc..ce1341c52 100644 --- a/util.c +++ b/util.c @@ -881,7 +881,7 @@ traverse(const char *dir, void (*fn)(const char *, struct stat *)) fname = format("%s/%s", dir, de->d_name); if (lstat(fname, &st)) { - if ((errno != ENOENT) && (errno != ESTALE)) { + if (errno != ENOENT && errno != ESTALE) { fatal("lstat %s failed: %s", fname, strerror(errno)); } free(fname); @@ -1510,7 +1510,7 @@ x_unlink(const char *path) } if (unlink(tmp_name) == -1) { /* If it was released in a race, that's OK. */ - if (errno != ENOENT) { + if (errno != ENOENT && errno != ESTALE) { result = -1; saved_errno = errno; }