Fixing locking

This commit is contained in:
Alex Yatskov 2015-07-06 17:56:12 +09:00
parent db22e54fa3
commit e9ef7d880d

12
dir.go
View File

@ -116,9 +116,6 @@ func (vd *verDir) createFile(name string, flags fuse.OpenFlags, mode os.FileMode
} }
func (vd *verDir) removeDir(name string) error { func (vd *verDir) removeDir(name string) error {
vd.mutex.Lock()
defer vd.mutex.Unlock()
if err := vd.version(); err != nil { if err := vd.version(); err != nil {
return err return err
} }
@ -132,14 +129,14 @@ func (vd *verDir) removeDir(name string) error {
vd.node.ver.meta.removeNode(node.path) vd.node.ver.meta.removeNode(node.path)
} }
vd.mutex.Lock()
delete(vd.dirs, name) delete(vd.dirs, name)
vd.mutex.Unlock()
return nil return nil
} }
func (vd *verDir) removeFile(name string) error { func (vd *verDir) removeFile(name string) error {
vd.mutex.Lock()
defer vd.mutex.Unlock()
if err := vd.version(); err != nil { if err := vd.version(); err != nil {
return err return err
} }
@ -153,7 +150,10 @@ func (vd *verDir) removeFile(name string) error {
vd.node.ver.meta.removeNode(node.path) vd.node.ver.meta.removeNode(node.path)
} }
vd.mutex.Lock()
delete(vd.files, name) delete(vd.files, name)
vd.mutex.Unlock()
return nil return nil
} }