From c43384aa1f4ab17d580a5e75db23dea1fff273a3 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Wed, 13 May 2026 07:59:07 -0500 Subject: [PATCH] Clarify releasedir readdir synchronization barrier - Document the lock/unlock pair as an acquire/release barrier. - Explain that releasedir waits for in-flight readdir calls before destroy/free. - Warn against removing the synchronization despite it not being a critical section. --- vendored/libfuse/lib/fuse.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vendored/libfuse/lib/fuse.cpp b/vendored/libfuse/lib/fuse.cpp index 92358e48..38a480df 100644 --- a/vendored/libfuse/lib/fuse.cpp +++ b/vendored/libfuse/lib/fuse.cpp @@ -2543,7 +2543,11 @@ fuse_lib_releasedir(fuse_req_t *req_, f.ops.releasedir(&req_->ctx, &ffi); - /* Done to keep race condition between last readdir reply and the unlock */ + // Acquire/release barrier: not a real critical section. A + // concurrent readdir may still hold dh->lock at this point. This + // lock+unlock pair blocks until the last readdir drops the lock + // guaranteeing that the subsequent destroy/free sees no in-flight + // readdir accessing dh->d. Do NOT remove. mutex_lock(dh->lock); mutex_unlock(dh->lock); mutex_destroy(dh->lock);