chunked: use a RWMutex for the cache

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2022-01-04 17:21:12 +01:00
parent 0d21b61022
commit 31b28dbedf
No known key found for this signature in database
GPG Key ID: 67E38F7A8BA21772
1 changed files with 3 additions and 3 deletions

View File

@ -45,7 +45,7 @@ type layersCache struct {
layers []layer
refs int
store storage.Store
mutex sync.Mutex
mutex sync.RWMutex
created time.Time
}
@ -465,8 +465,8 @@ func (c *layersCache) findDigestInternal(digest string) (string, string, int64,
return "", "", -1, nil
}
c.mutex.Lock()
defer c.mutex.Unlock()
c.mutex.RLock()
defer c.mutex.RUnlock()
for _, layer := range c.layers {
digest, off, len := findTag(digest, layer.metadata)