Commit 99167438 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Fix resync goroutine leak in ListAndWatch

Previously, we had no way to stop resync goroutine when ListAndWatch returned. goroutine leaked every time ListAndWatch returned, for example, with error. This commit adds another channel to signal that resync goroutine should exit when ListAndWatch returns.
parent 6abb4723
......@@ -259,12 +259,16 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error {
r.setLastSyncResourceVersion(resourceVersion)
resyncerrc := make(chan error, 1)
cancelCh := make(chan struct{})
defer close(cancelCh)
go func() {
for {
select {
case <-resyncCh:
case <-stopCh:
return
case <-cancelCh:
return
}
glog.V(4).Infof("%s: forcing resync", r.name)
if err := r.store.Resync(); err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment