cache: fix refs unlocking bug

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2018-04-30 10:38:47 -07:00
parent 2af19a8847
commit a7e72f85e9
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() cr.mu.Unlock()
usage, err := cr.cm.ManagerOpt.Snapshotter.Usage(ctx, driverID) usage, err := cr.cm.ManagerOpt.Snapshotter.Usage(ctx, driverID)
if err != nil { if err != nil {
if cr.isDead() { cr.mu.Lock()
isDead := cr.isDead()
cr.mu.Unlock() cr.mu.Unlock()
if isDead {
return int64(0), nil return int64(0), nil
} }
return s, errors.Wrapf(err, "failed to get usage for %s", cr.ID()) 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() cr.mu.Lock()
setSize(cr.md, usage.Size) setSize(cr.md, usage.Size)
if err := cr.md.Commit(); err != nil { if err := cr.md.Commit(); err != nil {
cr.mu.Unlock()
return s, err return s, err
} }
cr.mu.Unlock() cr.mu.Unlock()