summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@gnu.org>2015-03-01 00:08:40 +0100
committerAndreas Gruenbacher <agruen@gnu.org>2015-03-05 22:57:07 +0100
commit0d3df382d616f37efb5191548a22656f8494ca76 (patch)
treece421ce4b31853e6b5192d8c1046e7102e564b77
parent9f92e52c9fd3063abe0f4f6c80b2faf83163c905 (diff)
downloadpatch-0d3df382d616f37efb5191548a22656f8494ca76.tar.gz
Invalidate dirfd less aggressively
src/safe.c (safe_rename, safe_rmdir): Only invalidate cache entries when the underlying sycall succeeds and the entry actually goes away. This keeps the cache filled upon speculative rmdir when the directory may not be empty, for example.
-rw-r--r--src/safe.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/safe.c b/src/safe.c
index 129ccf4..69803ea 100644
--- a/src/safe.c
+++ b/src/safe.c
@@ -508,8 +508,11 @@ int safe_rename (const char *oldpath, const char *newpath)
return newdirfd;
ret = renameat (olddirfd, oldpath, newdirfd, newpath);
- invalidate_cached_dirfd (olddirfd, oldpath);
- invalidate_cached_dirfd (newdirfd, newpath);
+ if (! ret)
+ {
+ invalidate_cached_dirfd (olddirfd, oldpath);
+ invalidate_cached_dirfd (newdirfd, newpath);
+ }
return ret;
}
@@ -535,7 +538,8 @@ int safe_rmdir (const char *pathname)
return dirfd;
ret = unlinkat (dirfd, pathname, AT_REMOVEDIR);
- invalidate_cached_dirfd (dirfd, pathname);
+ if (! ret)
+ invalidate_cached_dirfd (dirfd, pathname);
return ret;
}