Browse Source

volume/local: fix race in List

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Alexander Morozov 9 years ago
parent
commit
3536c09cea
1 changed files with 2 additions and 0 deletions
  1. 2 0
      volume/local/local.go

+ 2 - 0
volume/local/local.go

@@ -117,9 +117,11 @@ type Root struct {
 // List lists all the volumes
 func (r *Root) List() ([]volume.Volume, error) {
 	var ls []volume.Volume
+	r.m.Lock()
 	for _, v := range r.volumes {
 		ls = append(ls, v)
 	}
+	r.m.Unlock()
 	return ls, nil
 }