Commit c5c77f10 authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher Committed by Han-Wen Nienhuys

nodefs: fix data race in Inode.Parent()

Inode.Parent() has to take the treeLock before looking
at the parents map.

Fixes https://github.com/hanwen/go-fuse/issues/166
parent b4cc1627
...@@ -94,6 +94,8 @@ func (n *Inode) Parent() (parent *Inode, name string) { ...@@ -94,6 +94,8 @@ func (n *Inode) Parent() (parent *Inode, name string) {
if n.mountPoint != nil { if n.mountPoint != nil {
return nil, "" return nil, ""
} }
n.mount.treeLock.RLock()
defer n.mount.treeLock.RUnlock()
for k := range n.parents { for k := range n.parents {
return k.parent, k.name return k.parent, k.name
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment