Skip to content

Commit

Permalink
Merge pull request #425 from nalind/mountslock
Browse files Browse the repository at this point in the history
layerStore.Load(): avoid double-locking the mounts list for Save
  • Loading branch information
umohnani8 authored Sep 11, 2019
2 parents 1201761 + 2fffa48 commit eef3c22
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func (r *layerStore) Load() error {
}
}
if shouldSave {
return r.Save()
return r.saveLayers()
}
}
return err
Expand Down Expand Up @@ -416,6 +416,16 @@ func (r *layerStore) loadMounts() error {
}

func (r *layerStore) Save() error {
r.mountsLockfile.Lock()
defer r.mountsLockfile.Unlock()
defer r.mountsLockfile.Touch()
if err := r.saveLayers(); err != nil {
return err
}
return r.saveMounts()
}

func (r *layerStore) saveLayers() error {
if !r.IsReadWrite() {
return errors.Wrapf(ErrStoreIsReadOnly, "not allowed to modify the layer store at %q", r.layerspath())
}
Expand All @@ -431,13 +441,7 @@ func (r *layerStore) Save() error {
return err
}
defer r.Touch()
if err := ioutils.AtomicWriteFile(rpath, jldata, 0600); err != nil {
return err
}
r.mountsLockfile.Lock()
defer r.mountsLockfile.Unlock()
defer r.mountsLockfile.Touch()
return r.saveMounts()
return ioutils.AtomicWriteFile(rpath, jldata, 0600)
}

func (r *layerStore) saveMounts() error {
Expand Down
2 changes: 1 addition & 1 deletion layers_ffjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eef3c22

Please sign in to comment.