Skip to content

Commit

Permalink
Merge pull request #1257 from tonistiigi/1903-fix-parent-release
Browse files Browse the repository at this point in the history
[19.03] cache: fix possible concurrent maps write on parent release
  • Loading branch information
tiborvass authored Nov 13, 2019
2 parents ff93519 + a393a76 commit 928f3b4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions cache/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ func (cr *cacheRecord) Mount(ctx context.Context, readonly bool) (snapshot.Mount
func (cr *cacheRecord) remove(ctx context.Context, removeSnapshot bool) error {
delete(cr.cm.records, cr.ID())
if cr.parent != nil {
if err := cr.parent.release(ctx); err != nil {
cr.parent.mu.Lock()
err := cr.parent.release(ctx)
cr.parent.mu.Unlock()
if err != nil {
return err
}
}
Expand Down Expand Up @@ -401,11 +404,6 @@ func (sr *mutableRef) release(ctx context.Context) error {
return err
}
}
if sr.parent != nil {
if err := sr.parent.release(ctx); err != nil {
return err
}
}
return sr.remove(ctx, true)
} else {
if sr.updateLastUsed() {
Expand Down

0 comments on commit 928f3b4

Please sign in to comment.