Skip to content

Commit 928f3b4

Browse files
authored
Merge pull request #1257 from tonistiigi/1903-fix-parent-release
[19.03] cache: fix possible concurrent maps write on parent release
2 parents ff93519 + a393a76 commit 928f3b4

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

cache/refs.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ func (cr *cacheRecord) Mount(ctx context.Context, readonly bool) (snapshot.Mount
185185
func (cr *cacheRecord) remove(ctx context.Context, removeSnapshot bool) error {
186186
delete(cr.cm.records, cr.ID())
187187
if cr.parent != nil {
188-
if err := cr.parent.release(ctx); err != nil {
188+
cr.parent.mu.Lock()
189+
err := cr.parent.release(ctx)
190+
cr.parent.mu.Unlock()
191+
if err != nil {
189192
return err
190193
}
191194
}
@@ -401,11 +404,6 @@ func (sr *mutableRef) release(ctx context.Context) error {
401404
return err
402405
}
403406
}
404-
if sr.parent != nil {
405-
if err := sr.parent.release(ctx); err != nil {
406-
return err
407-
}
408-
}
409407
return sr.remove(ctx, true)
410408
} else {
411409
if sr.updateLastUsed() {

0 commit comments

Comments
 (0)