Skip to content

Commit

Permalink
Only lock the primary layer store for reading in CreateImage
Browse files Browse the repository at this point in the history
There seems to be no reason to lock for writing.

Signed-off-by: Miloslav Trmač <[email protected]>
  • Loading branch information
mtrmac committed Oct 13, 2022
1 parent 12a91da commit 695ca11
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1199,22 +1199,14 @@ func (s *store) CreateLayer(id, parent string, names []string, mountLabel string

func (s *store) CreateImage(id string, names []string, layer, metadata string, options *ImageOptions) (*Image, error) {
if layer != "" {
lstore, err := s.getLayerStore()
if err != nil {
return nil, err
}
lstores, err := s.getROLayerStores()
layerStores, err := s.allLayerStores()
if err != nil {
return nil, err
}
var ilayer *Layer
for _, s := range append([]roLayerStore{lstore}, lstores...) {
for _, s := range layerStores {
store := s
if store == lstore {
store.Lock()
} else {
store.RLock()
}
store.RLock()
defer store.Unlock()
err := store.ReloadIfChanged()
if err != nil {
Expand Down

0 comments on commit 695ca11

Please sign in to comment.