Skip to content

Commit

Permalink
Merge pull request containers#214 from nalind/hold-locks
Browse files Browse the repository at this point in the history
Hold the layer store lock while diffing
  • Loading branch information
rhatdan authored Sep 14, 2018
2 parents 243c4cd + 3df3c9f commit 02db7cb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2369,13 +2369,23 @@ func (s *store) Diff(from, to string, options *DiffOptions) (io.ReadCloser, erro
}
for _, store := range append([]ROLayerStore{lstore}, lstores...) {
store.Lock()
defer store.Unlock()
if modified, err := store.Modified(); modified || err != nil {
store.Load()
}
if store.Exists(to) {
return store.Diff(from, to, options)
rc, err := store.Diff(from, to, options)
if rc != nil && err == nil {
wrapped := ioutils.NewReadCloserWrapper(rc, func() error {
err := rc.Close()
store.Unlock()
return err
})
return wrapped, nil
}
store.Unlock()
return rc, err
}
store.Unlock()
}
return nil, ErrLayerUnknown
}
Expand Down

0 comments on commit 02db7cb

Please sign in to comment.