mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 07:34:04 -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.
|
||||
func (sp *scrapePool) stop() {
|
||||
var wg sync.WaitGroup
|
||||
|
|
|
@ -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…
Reference in a new issue