mirror of https://github.com/k3s-io/k3s
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.pull/6/head
parent
6abb472357
commit
991674380b
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue