mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
apiserver: fix Cacher.Stop() race
This commit is contained in:
parent
210626577b
commit
a30c0f477d
@ -649,13 +649,15 @@ func (c *Cacher) isStopped() bool {
|
||||
}
|
||||
|
||||
func (c *Cacher) Stop() {
|
||||
// TODO : Do not check for isStopped (and return) when PR
|
||||
// https://github.com/kubernetes/kubernetes/pull/50690
|
||||
// merges as that shuts down storage properly
|
||||
// avoid stopping twice (note: cachers are shared with subresources)
|
||||
if c.isStopped() {
|
||||
return
|
||||
}
|
||||
c.stopLock.Lock()
|
||||
if c.stopped {
|
||||
// avoid that it was locked meanwhile as isStopped only read-locks
|
||||
return
|
||||
}
|
||||
c.stopped = true
|
||||
c.stopLock.Unlock()
|
||||
close(c.stopCh)
|
||||
|
Loading…
Reference in New Issue
Block a user