Git commit mutex changes

This commit is contained in:
Alex Yatskov 2015-06-22 19:38:11 +09:00
parent f5d16cc423
commit 4e793c7b5a

12
dir.go
View File

@ -116,6 +116,9 @@ 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
} }
@ -129,14 +132,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
} }
@ -150,10 +153,7 @@ 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
} }