mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-19 01:27:10 +00:00
Call the right cleanup function
Kubernetes-commit: 1ab88c94e8e3b9ccfe16b2b0dbf26f688be1d4df
This commit is contained in:
parent
e1798d5fa2
commit
174c4c21d7
6
tools/cache/reflector.go
vendored
6
tools/cache/reflector.go
vendored
@ -239,8 +239,6 @@ func (r *Reflector) resyncChan() (<-chan time.Time, func() bool) {
|
||||
func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error {
|
||||
glog.V(3).Infof("Listing and watching %v from %s", r.expectedType, r.name)
|
||||
var resourceVersion string
|
||||
resyncCh, cleanup := r.resyncChan()
|
||||
defer cleanup()
|
||||
|
||||
// Explicitly set "0" as resource version - it's fine for the List()
|
||||
// to be served from cache and potentially be delayed relative to
|
||||
@ -272,6 +270,10 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error {
|
||||
cancelCh := make(chan struct{})
|
||||
defer close(cancelCh)
|
||||
go func() {
|
||||
resyncCh, cleanup := r.resyncChan()
|
||||
defer func() {
|
||||
cleanup() // Call the last one written into cleanup
|
||||
}()
|
||||
for {
|
||||
select {
|
||||
case <-resyncCh:
|
||||
|
Loading…
Reference in New Issue
Block a user