From f63f6cb18753605cac71973cd90becf651794d9f 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..2276cbf7 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 laast readdir drop the lock + // guarenteeing that the subsequent destroy/free sees no in-flight + // readdir accessing dh->d. Do NOT not remove. mutex_lock(dh->lock); mutex_unlock(dh->lock); mutex_destroy(dh->lock);