Merge pull request #357 from tonistiigi/unlock-bug

cache: fix refs unlocking bug
docker-18.09
Akihiro Suda 2018-05-01 13:00:10 +09:00 committed by GitHub
commit 0e42bcebe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

5
cache/refs.go vendored
View File

@ -93,8 +93,10 @@ func (cr *cacheRecord) Size(ctx context.Context) (int64, error) {
cr.mu.Unlock()
usage, err := cr.cm.ManagerOpt.Snapshotter.Usage(ctx, driverID)
if err != nil {
if cr.isDead() {
cr.mu.Lock()
isDead := cr.isDead()
cr.mu.Unlock()
if isDead {
return int64(0), nil
}
return s, errors.Wrapf(err, "failed to get usage for %s", cr.ID())
@ -102,6 +104,7 @@ func (cr *cacheRecord) Size(ctx context.Context) (int64, error) {
cr.mu.Lock()
setSize(cr.md, usage.Size)
if err := cr.md.Commit(); err != nil {
cr.mu.Unlock()
return s, err
}
cr.mu.Unlock()