FUSE mount: prevent concurrent modification

This commit is contained in:
Chris Lu 2020-06-26 10:00:48 -07:00
parent 3cec4b3c49
commit 48b23f2fdd

View file

@ -1,6 +1,8 @@
package bounded_tree package bounded_tree
import ( import (
"sync"
"github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/util"
) )
@ -13,6 +15,7 @@ type Node struct {
type BoundedTree struct { type BoundedTree struct {
root *Node root *Node
sync.Mutex
} }
func NewBoundedTree() *BoundedTree { func NewBoundedTree() *BoundedTree {
@ -30,8 +33,8 @@ type VisitNodeFunc func(path util.FullPath) (childDirectories []string, err erro
// A leaf node, which has no children, represents a directory not visited. // A leaf node, which has no children, represents a directory not visited.
// A non-leaf node or a non-existing node represents a directory already visited, or does not need to visit. // A non-leaf node or a non-existing node represents a directory already visited, or does not need to visit.
func (t *BoundedTree) EnsureVisited(p util.FullPath, visitFn VisitNodeFunc) { func (t *BoundedTree) EnsureVisited(p util.FullPath, visitFn VisitNodeFunc) {
// println() t.Lock()
// println("EnsureVisited", p) defer t.Unlock()
if t.root == nil { if t.root == nil {
return return