From 3911a4925690da4d249aa527533059cd489ceb7c Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 2 Apr 2020 21:14:45 +0100 Subject: [PATCH] vfs: make File lock and Dir lock not overlap to avoid deadlock This was caused by this commit which wasn't part of 1.51.0 3c91abce745000cd vfs: fix race condition caused by unlocked reading of Dir.path --- vfs/file.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vfs/file.go b/vfs/file.go index f5e527f07..44231d38f 100644 --- a/vfs/file.go +++ b/vfs/file.go @@ -97,8 +97,9 @@ func (f *File) _path() string { // Path returns the full path of the file func (f *File) Path() string { f.mu.RLock() - defer f.mu.RUnlock() - return f._path() + d, leaf := f.d, f.leaf + f.mu.RUnlock() + return path.Join(d.Path(), leaf) } // osPath returns the full path of the file in the cache in OS format