diff options
author | Andreas Gruenbacher <agruen@gnu.org> | 2015-03-01 00:08:40 +0100 |
---|---|---|
committer | Andreas Gruenbacher <agruen@gnu.org> | 2015-03-05 22:57:07 +0100 |
commit | 0d3df382d616f37efb5191548a22656f8494ca76 (patch) | |
tree | ce421ce4b31853e6b5192d8c1046e7102e564b77 | |
parent | 9f92e52c9fd3063abe0f4f6c80b2faf83163c905 (diff) | |
download | patch-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.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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; } |