From 611ddc10b0d6ed0018a8667df7d031c2f35e5a6a Mon Sep 17 00:00:00 2001 From: auxten Date: Sun, 13 Sep 2020 20:58:28 +0800 Subject: [PATCH] Fix misusage of RLock in timeCache lru.Cache.Get() --- pkg/kubelet/time_cache.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/kubelet/time_cache.go b/pkg/kubelet/time_cache.go index 66528e25729..d5929efbf10 100644 --- a/pkg/kubelet/time_cache.go +++ b/pkg/kubelet/time_cache.go @@ -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