mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Merge pull request #76795 from tedyu/cacher-read
Use read lock in ready#check
This commit is contained in:
commit
24c964d5c1
@ -1245,7 +1245,7 @@ type ready struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newReady() *ready {
|
func newReady() *ready {
|
||||||
return &ready{c: sync.NewCond(&sync.Mutex{})}
|
return &ready{c: sync.NewCond(&sync.RWMutex{})}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ready) wait() {
|
func (r *ready) wait() {
|
||||||
@ -1259,8 +1259,9 @@ func (r *ready) wait() {
|
|||||||
// TODO: Make check() function more sophisticated, in particular
|
// TODO: Make check() function more sophisticated, in particular
|
||||||
// allow it to behave as "waitWithTimeout".
|
// allow it to behave as "waitWithTimeout".
|
||||||
func (r *ready) check() bool {
|
func (r *ready) check() bool {
|
||||||
r.c.L.Lock()
|
rwMutex := r.c.L.(*sync.RWMutex)
|
||||||
defer r.c.L.Unlock()
|
rwMutex.RLock()
|
||||||
|
defer rwMutex.RUnlock()
|
||||||
return r.ok
|
return r.ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user