Merge pull request #1116 from prometheus/fix-tm-done

Fix target manager CPU busyloop caused by bad done-channel handling.
This commit is contained in:
Julius Volz 2015-09-28 12:31:26 +02:00
commit e91d85b498
1 changed files with 6 additions and 6 deletions

View File

@ -128,14 +128,14 @@ func (tm *TargetManager) Run() {
tgc := make(chan *config.TargetGroup) tgc := make(chan *config.TargetGroup)
// Run the target provider after cleanup of the stale targets is done. // Run the target provider after cleanup of the stale targets is done.
defer func(prov TargetProvider, tgc chan *config.TargetGroup) { defer func(prov TargetProvider, tgc chan<- *config.TargetGroup, done <-chan struct{}) {
go prov.Run(tgc, tm.done) go prov.Run(tgc, done)
}(prov, tgc) }(prov, tgc, tm.done)
tgupc := make(chan targetGroupUpdate) tgupc := make(chan targetGroupUpdate)
updates = append(updates, tgupc) updates = append(updates, tgupc)
go func(scfg *config.ScrapeConfig) { go func(scfg *config.ScrapeConfig, done <-chan struct{}) {
defer close(tgupc) defer close(tgupc)
for { for {
select { select {
@ -144,11 +144,11 @@ func (tm *TargetManager) Run() {
break break
} }
tgupc <- targetGroupUpdate{tg: tg, scfg: scfg} tgupc <- targetGroupUpdate{tg: tg, scfg: scfg}
case <-tm.done: case <-done:
return return
} }
} }
}(scfg) }(scfg, tm.done)
} }
} }