Skip to content

Commit

Permalink
Fix accessing containers and image locks
Browse files Browse the repository at this point in the history
Match containers and image lock to the new layer lock method.
in containers#1351

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Sep 28, 2022
1 parent dcb8b68 commit c9c7d28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,6 @@ func newContainerStore(dir string) (ContainerStore, error) {
if err != nil {
return nil, err
}
lockfile.Lock()
defer lockfile.Unlock()
cstore := containerStore{
lockfile: lockfile,
dir: dir,
Expand All @@ -265,6 +263,8 @@ func newContainerStore(dir string) (ContainerStore, error) {
bylayer: make(map[string]*Container),
byname: make(map[string]*Container),
}
cstore.Lock()
defer cstore.Unlock()
if err := cstore.Load(); err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions images.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,6 @@ func newImageStore(dir string) (ImageStore, error) {
if err != nil {
return nil, err
}
lockfile.Lock()
defer lockfile.Unlock()
istore := imageStore{
lockfile: lockfile,
dir: dir,
Expand All @@ -346,6 +344,8 @@ func newImageStore(dir string) (ImageStore, error) {
byname: make(map[string]*Image),
bydigest: make(map[digest.Digest][]*Image),
}
istore.Lock()
defer istore.Unlock()
if err := istore.Load(); err != nil {
return nil, err
}
Expand All @@ -357,8 +357,6 @@ func newROImageStore(dir string) (ROImageStore, error) {
if err != nil {
return nil, err
}
lockfile.RLock()
defer lockfile.Unlock()
istore := imageStore{
lockfile: lockfile,
dir: dir,
Expand All @@ -367,6 +365,8 @@ func newROImageStore(dir string) (ROImageStore, error) {
byname: make(map[string]*Image),
bydigest: make(map[digest.Digest][]*Image),
}
istore.RLock()
defer istore.Unlock()
if err := istore.Load(); err != nil {
return nil, err
}
Expand Down

0 comments on commit c9c7d28

Please sign in to comment.