Commit 1830098f authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Prevent deadlocks by moving notify outside of mutex.

parent dd451fd6
...@@ -167,16 +167,19 @@ func (me *MemUnionFs) Update(results map[string]*Result) { ...@@ -167,16 +167,19 @@ func (me *MemUnionFs) Update(results map[string]*Result) {
} }
me.mutex.Lock() me.mutex.Lock()
defer me.mutex.Unlock() notifyNodes := []*fuse.Inode{}
enotifyNodes := []*fuse.Inode{}
enotifyNames := []string{}
sort.Strings(add) sort.Strings(add)
for _, n := range add { for _, n := range add {
node, rest := me.connector.Node(me.root.Inode(), n) node, rest := me.connector.Node(me.root.Inode(), n)
if len(rest) > 0 { if len(rest) > 0 {
me.connector.EntryNotify(node, rest[0]) enotifyNames = append(enotifyNames, rest[0])
enotifyNodes = append(enotifyNodes, node)
continue continue
} }
me.connector.FileNotify(node, 0, 0) notifyNodes = append(notifyNodes, node)
mn := node.FsNode().(*memNode) mn := node.FsNode().(*memNode)
mn.original = n mn.original = n
mn.changed = false mn.changed = false
...@@ -185,6 +188,14 @@ func (me *MemUnionFs) Update(results map[string]*Result) { ...@@ -185,6 +188,14 @@ func (me *MemUnionFs) Update(results map[string]*Result) {
mn.info = *r.FileInfo mn.info = *r.FileInfo
mn.link = r.Link mn.link = r.Link
} }
me.mutex.Unlock()
for _, n := range notifyNodes {
me.connector.FileNotify(n, 0, 0)
}
for i, n := range enotifyNodes {
me.connector.EntryNotify(n, enotifyNames[i])
}
} }
func (me *MemUnionFs) getFilename() string { func (me *MemUnionFs) getFilename() string {
...@@ -372,7 +383,6 @@ func (me *memNode) Rename(oldName string, newParent fuse.FsNode, newName string, ...@@ -372,7 +383,6 @@ func (me *memNode) Rename(oldName string, newParent fuse.FsNode, newName string,
me.fs.deleted[filepath.Join(newParent.(*memNode).original, newName)] = true me.fs.deleted[filepath.Join(newParent.(*memNode).original, newName)] = true
} }
log.Println("materialize")
mn.materialize() mn.materialize()
mn.markChanged() mn.markChanged()
} }
......
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