Browse Source

Fix potential race in ctx intialization

pull/1527/head
Fabian Reinartz 9 years ago
parent
commit
769389e559
  1. 7
      retrieval/scrape.go
  2. 2
      retrieval/targetmanager.go

7
retrieval/scrape.go

@ -130,6 +130,13 @@ func newScrapePool(cfg *config.ScrapeConfig, app storage.SampleAppender) *scrape
}
}
func (sp *scrapePool) init(ctx context.Context) {
sp.mtx.Lock()
defer sp.mtx.Unlock()
sp.ctx = ctx
}
// stop terminates all scrape loops and returns after they all terminated.
func (sp *scrapePool) stop() {
var wg sync.WaitGroup

2
retrieval/targetmanager.go

@ -224,7 +224,7 @@ func (ts *targetSet) reload(cfg *config.ScrapeConfig) {
func (ts *targetSet) runScraping(ctx context.Context) {
ctx, ts.cancelScraping = context.WithCancel(ctx)
ts.scrapePool.ctx = ctx
ts.scrapePool.init(ctx)
Loop:
for {

Loading…
Cancel
Save