hold listener lock while waiting for goroutines to finish

Kubernetes-commit: 7ce19b75a8dbca12837ed9f4c5c2828c38b82a03
This commit is contained in:
Alexander Zielenski 2022-08-29 12:34:35 -07:00 committed by Kubernetes Publisher
parent e11a988e1c
commit 93e5e0e8a0

View File

@ -751,7 +751,6 @@ func (p *sharedProcessor) run(stopCh <-chan struct{}) {
}()
<-stopCh
func() {
p.listenersLock.Lock()
defer p.listenersLock.Unlock()
for listener := range p.listeners {
@ -762,10 +761,8 @@ func (p *sharedProcessor) run(stopCh <-chan struct{}) {
// (processorListener cannot be re-used)
p.listeners = nil
// Reset to false since there are nil listeners, also to block new listeners
// that are added from being run now that the processor was stopped
// Reset to false since no listeners are running
p.listenersStarted = false
}()
p.wg.Wait() // Wait for all .pop() and .run() to stop
}
@ -789,7 +786,6 @@ func (p *sharedProcessor) shouldResync() bool {
listener.determineNextResync(now)
}
}
return resyncNeeded
}