Skip to content

Commit 24c964d

Browse files
authored
Merge pull request kubernetes#76795 from tedyu/cacher-read
Use read lock in ready#check
2 parents 2776cc1 + 04a7b50 commit 24c964d

File tree

1 file changed

+4
-3
lines changed
  • staging/src/k8s.io/apiserver/pkg/storage/cacher

1 file changed

+4
-3
lines changed

staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ type ready struct {
12451245
}
12461246

12471247
func newReady() *ready {
1248-
return &ready{c: sync.NewCond(&sync.Mutex{})}
1248+
return &ready{c: sync.NewCond(&sync.RWMutex{})}
12491249
}
12501250

12511251
func (r *ready) wait() {
@@ -1259,8 +1259,9 @@ func (r *ready) wait() {
12591259
// TODO: Make check() function more sophisticated, in particular
12601260
// allow it to behave as "waitWithTimeout".
12611261
func (r *ready) check() bool {
1262-
r.c.L.Lock()
1263-
defer r.c.L.Unlock()
1262+
rwMutex := r.c.L.(*sync.RWMutex)
1263+
rwMutex.RLock()
1264+
defer rwMutex.RUnlock()
12641265
return r.ok
12651266
}
12661267

0 commit comments

Comments
 (0)