mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Merge pull request #1527 from prometheus/fabxc/fixrace
Fix potential race in ctx intialization
This commit is contained in:
commit
da701f9d13
|
@ -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.
|
// stop terminates all scrape loops and returns after they all terminated.
|
||||||
func (sp *scrapePool) stop() {
|
func (sp *scrapePool) stop() {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
|
@ -224,7 +224,7 @@ func (ts *targetSet) reload(cfg *config.ScrapeConfig) {
|
||||||
func (ts *targetSet) runScraping(ctx context.Context) {
|
func (ts *targetSet) runScraping(ctx context.Context) {
|
||||||
ctx, ts.cancelScraping = context.WithCancel(ctx)
|
ctx, ts.cancelScraping = context.WithCancel(ctx)
|
||||||
|
|
||||||
ts.scrapePool.ctx = ctx
|
ts.scrapePool.init(ctx)
|
||||||
|
|
||||||
Loop:
|
Loop:
|
||||||
for {
|
for {
|
||||||
|
|
Loading…
Reference in a new issue