ensure the cluster channel is closed once

This commit is contained in:
Travis Nielsen committed 2017-04-28 13:51:12 -07:00
1 parent 4c111f0da1
commit 012b7cc2dc
1 file changed
+8 -4
+8 -4
View File
@@ -21,9 +21,9 @@ package operator
import "sync"
type tprTracker struct {
stopChMap map[string]chan struct{}
clusterRVs map[string]string
waitCluster sync.WaitGroup
stopChMap map[string]chan struct{}
clusterRVs map[string]string
sync.RWMutex
}
func newTPRTracker() *tprTracker {
@@ -43,6 +43,8 @@ func (t *tprTracker) add(name, version string) {
func (t *tprTracker) remove(name string) {
delete(t.clusterRVs, name)
t.Lock()
defer t.Unlock()
if stopCh, ok := t.stopChMap[name]; ok {
close(stopCh)
}
@@ -50,8 +52,10 @@ func (t *tprTracker) remove(name string) {
}
func (t *tprTracker) stop() {
t.Lock()
defer t.Unlock()
for _, stop := range t.stopChMap {
close(stop)
}
t.waitCluster.Wait()
t.stopChMap = map[string]chan struct{}{}
}