diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2016-02-20 17:10:19 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2016-02-20 17:10:19 -0500 |
commit | 0193e24a32a3b3663cf8a55a89e3f2a1dcfa7ff7 (patch) | |
tree | 05d10c9e808c06b12142e810f1e26a4e2c34d2a4 /bftw.c | |
parent | 806e8504a374c7cf546a1ce0a81ed2ba954c3096 (diff) | |
download | bfs-0193e24a32a3b3663cf8a55a89e3f2a1dcfa7ff7.tar.xz |
bftw: Shrink the LRU before finding the parent.
Otherwise we might close the found parent.
Diffstat (limited to 'bftw.c')
-rw-r--r-- | bftw.c | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -328,16 +328,14 @@ static bool dircache_should_retry(struct dircache *cache, const struct dircache_ static DIR *dircache_entry_open(struct dircache *cache, struct dircache_entry *entry, const char *path) { assert(!entry->fd); - DIR *dir = NULL; + if (cache->lru_remaining == 0) { + dircache_entry_close(cache, cache->lru_tail); + } int at_fd = AT_FDCWD; const char *at_path = path; struct dircache_entry *base = dircache_entry_base(cache, entry, &at_fd, &at_path); - if (cache->lru_remaining == 0) { - dircache_entry_close(cache, cache->lru_tail); - } - int flags = O_DIRECTORY; int fd = openat(at_fd, at_path, flags); @@ -345,7 +343,7 @@ static DIR *dircache_entry_open(struct dircache *cache, struct dircache_entry *e fd = openat(at_fd, at_path, flags); } if (fd < 0) { - goto done; + return NULL; } entry->fd = fd; @@ -362,15 +360,13 @@ static DIR *dircache_entry_open(struct dircache *cache, struct dircache_entry *e fd = dup(entry->fd); } if (fd < 0) { - goto done; + return NULL; } - dir = fdopendir(fd); + DIR *dir = fdopendir(fd); if (!dir) { close(fd); } - -done: return dir; } |