aboutsummaryrefslogtreecommitdiff
path: root/weed/util/bounded_tree/bounded_tree.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-06-26 10:00:48 -0700
committerChris Lu <chris.lu@gmail.com>2020-06-26 10:00:48 -0700
commit48b23f2fdd8ba48fb2b99ea7e765bbfb57c9554e (patch)
tree84c0df76f4520cbbbe915ed223ca71ffacff3a8b /weed/util/bounded_tree/bounded_tree.go
parent3cec4b3c49b4d0c364d2b864048b53d2c04b9625 (diff)
downloadseaweedfs-48b23f2fdd8ba48fb2b99ea7e765bbfb57c9554e.tar.xz
seaweedfs-48b23f2fdd8ba48fb2b99ea7e765bbfb57c9554e.zip
FUSE mount: prevent concurrent modification
Diffstat (limited to 'weed/util/bounded_tree/bounded_tree.go')
-rw-r--r--weed/util/bounded_tree/bounded_tree.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/weed/util/bounded_tree/bounded_tree.go b/weed/util/bounded_tree/bounded_tree.go
index 8c99ad83d..40b9c4e47 100644
--- a/weed/util/bounded_tree/bounded_tree.go
+++ b/weed/util/bounded_tree/bounded_tree.go
@@ -1,6 +1,8 @@
package bounded_tree
import (
+ "sync"
+
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/util"
)
@@ -13,6 +15,7 @@ type Node struct {
type BoundedTree struct {
root *Node
+ sync.Mutex
}
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 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) {
- // println()
- // println("EnsureVisited", p)
+ t.Lock()
+ defer t.Unlock()
if t.root == nil {
return