Merge pull request #55169 from sttts/sttts-cache-stop-race
Automatic merge from submit-queue (batch tested with PRs 55169, 54990). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. apiserver: fix Cacher.Stop() race Kubernetes-commit: 7966af637ed34b40e73b9a3c361a614e9ce3fc86
This commit is contained in:
		
						commit
						baff305a6c
					
				
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							|  | @ -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