Browse Source

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

Jakob Borg 11 years ago
parent
commit
a26ce61d92
1 changed files with 2 additions and 2 deletions
  1. 2 2
      model/filequeue.go

+ 2 - 2
model/filequeue.go

@@ -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