mirror of
https://github.com/moby/buildkit.git
synced 2026-06-30 19:57:39 +00:00
contenthash: data race
Multiple calls to GetCacheContext may occur from multiple threads; however they should only occur when dealing with an ImmutableRef. For this case we still need to perform a lock to prevent data race warnings; however in reality the linkMap will be unused. Signed-off-by: Alex Couture-Beil <alex@earthly.dev>
This commit is contained in:
committed by
Alex Couture-Beil
parent
86b22f7eb2
commit
caa9579cb0
2
cache/contenthash/checksum.go
vendored
2
cache/contenthash/checksum.go
vendored
@@ -110,7 +110,9 @@ func (cm *cacheManager) GetCacheContext(ctx context.Context, md cache.RefMetadat
|
||||
cm.lruMu.Unlock()
|
||||
if ok {
|
||||
cm.locker.Unlock(md.ID())
|
||||
v.(*cacheContext).mu.Lock() // locking is required because multiple ImmutableRefs can reach this code; however none of them use the linkMap.
|
||||
v.(*cacheContext).linkMap = map[string][][]byte{}
|
||||
v.(*cacheContext).mu.Unlock()
|
||||
return v.(*cacheContext), nil
|
||||
}
|
||||
cc, err := newCacheContext(md)
|
||||
|
||||
Reference in New Issue
Block a user