Skip to content

Commit 72fd4dc

Browse files
authored
lock while reading map (#30)
1 parent d1ce0d5 commit 72fd4dc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,13 @@ func (c *BlobCacheClient) manageLocalClientCache(ttl time.Duration, interval tim
332332
now := time.Now()
333333
stale := make([]string, 0)
334334

335+
c.mu.RLock()
335336
for hash, entry := range c.localHostCache {
336337
if now.Sub(entry.timestamp) > ttl {
337338
stale = append(stale, hash)
338339
}
339340
}
340-
341+
c.mu.RUnlock()
341342
c.mu.Lock()
342343
for _, hash := range stale {
343344
delete(c.localHostCache, hash)

0 commit comments

Comments
 (0)