mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
volumes: add synchronization to Count and List
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
59311faaed
commit
2d21996eec
1 changed files with 4 additions and 0 deletions
|
@ -227,6 +227,8 @@ func (s *volumeStore) Decrement(v volume.Volume) {
|
||||||
|
|
||||||
// Count returns the usage count of the passed in volume
|
// Count returns the usage count of the passed in volume
|
||||||
func (s *volumeStore) Count(v volume.Volume) int {
|
func (s *volumeStore) Count(v volume.Volume) int {
|
||||||
|
s.mu.Lock()
|
||||||
|
defer s.mu.Unlock()
|
||||||
vc, exists := s.vols[v.Name()]
|
vc, exists := s.vols[v.Name()]
|
||||||
if !exists {
|
if !exists {
|
||||||
return 0
|
return 0
|
||||||
|
@ -236,6 +238,8 @@ func (s *volumeStore) Count(v volume.Volume) int {
|
||||||
|
|
||||||
// List returns all the available volumes
|
// List returns all the available volumes
|
||||||
func (s *volumeStore) List() []volume.Volume {
|
func (s *volumeStore) List() []volume.Volume {
|
||||||
|
s.mu.Lock()
|
||||||
|
defer s.mu.Unlock()
|
||||||
var ls []volume.Volume
|
var ls []volume.Volume
|
||||||
for _, vc := range s.vols {
|
for _, vc := range s.vols {
|
||||||
ls = append(ls, vc.Volume)
|
ls = append(ls, vc.Volume)
|
||||||
|
|
Loading…
Add table
Reference in a new issue