From 04a7b50a020906e8e5cd32dfce378125606ce97d Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Thu, 18 Apr 2019 14:00:42 -0700 Subject: [PATCH] Use read lock in ready#check --- staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go index cb1e11437aa..19a2841fc9f 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go @@ -1245,7 +1245,7 @@ type ready struct { } func newReady() *ready { - return &ready{c: sync.NewCond(&sync.Mutex{})} + return &ready{c: sync.NewCond(&sync.RWMutex{})} } func (r *ready) wait() { @@ -1259,8 +1259,9 @@ func (r *ready) wait() { // TODO: Make check() function more sophisticated, in particular // allow it to behave as "waitWithTimeout". func (r *ready) check() bool { - r.c.L.Lock() - defer r.c.L.Unlock() + rwMutex := r.c.L.(*sync.RWMutex) + rwMutex.RLock() + defer rwMutex.RUnlock() return r.ok }