(Re)Fix locking around deleteFile (fixes #64)

This commit is contained in:
Jakob Borg 2014-02-11 16:04:55 +01:00
parent 478300f6d8
commit a26ce61d92

View File

@ -221,6 +221,8 @@ func (q *FileQueue) SetAvailable(file string, nodes []string) {
func (q *FileQueue) RemoveAvailable(toRemove string) {
q.amut.Lock()
q.fmut.Lock()
defer q.fmut.Unlock()
defer q.amut.Unlock()
for file, nodes := range q.availability {
@ -228,9 +230,7 @@ func (q *FileQueue) RemoveAvailable(toRemove string) {
if node == toRemove {
q.availability[file] = nodes[:i+copy(nodes[i:], nodes[i+1:])]
if len(q.availability[file]) == 0 {
q.fmut.Lock()
q.deleteFile(file)
q.fmut.Unlock()
}
}
break