Browse Source

volume/local: fix race in List

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Alexander Morozov 9 năm trước cách đây
mục cha
commit
3536c09cea
1 tập tin đã thay đổi với 2 bổ sung0 xóa
  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
 }