Hmm, interesting.
-- >8 --
Subject: allow readdir(3) to return the same entry twice
When removing a large directory recursively, repeatedly running unlink(2)
on what we read from readdir(3) can cause readdir(3) (or underlying
getdents(2)) to return the same entry twice. If we have already removed
it, running lstat() on the entry would fail with ENOENT, but there is no
harm if we ignore such an error.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
dir.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git i/dir.c w/dir.c
index 0131983..293df4e 100644
--- i/dir.c
+++ w/dir.c
@@ -800,8 +800,11 @@ int remove_dir_recursively(struct strbuf *path, int only_empty)
strbuf_setlen(path, len);
strbuf_addstr(path, e->d_name);
- if (lstat(path->buf, &st))
- ; /* fall thru */
+ if (lstat(path->buf, &st)) {
+ if (errno == ENOENT)
+ continue;
+ /* otherwise fall thru */
+ }
else if (S_ISDIR(st.st_mode)) {
if (!remove_dir_recursively(path, only_empty))
continue; /* happy */
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html