Skip to content

Commit 9a99756

Browse files
authored
Merge pull request #16 from lochjin/v1.10.21-qng
common/lru: fix race in lru (ethereum#26164)
2 parents cc71c53 + 22ef7c2 commit 9a99756

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

common/lru/blob_lru.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type SizeConstrainedLRU struct {
3333
size uint64
3434
maxSize uint64
3535
lru *simplelru.LRU
36-
lock sync.RWMutex
36+
lock sync.Mutex
3737
}
3838

3939
// NewSizeConstrainedLRU creates a new SizeConstrainedLRU.
@@ -78,8 +78,8 @@ func (c *SizeConstrainedLRU) Add(key common.Hash, value []byte) (evicted bool) {
7878

7979
// Get looks up a key's value from the cache.
8080
func (c *SizeConstrainedLRU) Get(key common.Hash) []byte {
81-
c.lock.RLock()
82-
defer c.lock.RUnlock()
81+
c.lock.Lock()
82+
defer c.lock.Unlock()
8383

8484
if v, ok := c.lru.Get(key); ok {
8585
return v.([]byte)

0 commit comments

Comments
 (0)