Merge "Fix deadlock while invalidating VFS dentry" into rvc-dev
diff --git a/jni/FuseDaemon.cpp b/jni/FuseDaemon.cpp
index 7f95186..4d586d1 100644
--- a/jni/FuseDaemon.cpp
+++ b/jni/FuseDaemon.cpp
@@ -1532,16 +1532,22 @@
void FuseDaemon::InvalidateFuseDentryCache(const std::string& path) {
LOG(VERBOSE) << "Invalidating FUSE dentry cache";
if (active.load(std::memory_order_acquire)) {
- std::lock_guard<std::recursive_mutex> guard(fuse->lock);
+ string name;
+ fuse_ino_t parent;
- const node* node = node::LookupAbsolutePath(fuse->root, path);
- if (node) {
- string name = node->GetName();
- fuse_ino_t parent = fuse->ToInode(node->GetParent());
- if (fuse_lowlevel_notify_inval_entry(fuse->se, parent, name.c_str(), name.size())) {
- LOG(WARNING) << "Failed to invalidate dentry for path";
+ {
+ std::lock_guard<std::recursive_mutex> guard(fuse->lock);
+ const node* node = node::LookupAbsolutePath(fuse->root, path);
+ if (node) {
+ name = node->GetName();
+ parent = fuse->ToInode(node->GetParent());
}
}
+
+ if (!name.empty() &&
+ fuse_lowlevel_notify_inval_entry(fuse->se, parent, name.c_str(), name.size())) {
+ LOG(WARNING) << "Failed to invalidate dentry for path";
+ }
} else {
LOG(WARNING) << "FUSE daemon is inactive. Cannot invalidate dentry";
}