Merge pull request #94751 from sensesai/senses/fixLruCache

Fix misusage of RLock in timeCache lru.Cache.Get()
This commit is contained in:
Kubernetes Prow Robot 2020-09-14 08:11:12 -07:00 committed by GitHub
commit 3dc6f74d04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,7 +27,7 @@ import (
// timeCache stores a time keyed by uid
type timeCache struct {
lock sync.RWMutex
lock sync.Mutex
cache *lru.Cache
}
@ -53,8 +53,8 @@ func (c *timeCache) Remove(uid types.UID) {
}
func (c *timeCache) Get(uid types.UID) (time.Time, bool) {
c.lock.RLock()
defer c.lock.RUnlock()
c.lock.Lock()
defer c.lock.Unlock()
value, ok := c.cache.Get(uid)
if !ok {
return time.Time{}, false