hotfix(boringpoll): fix race condition on stop

This commit is contained in:
Quentin McGaw
2026-04-19 17:48:38 +00:00
parent 44977f4d9e
commit e87a92efa0
+3 -2
View File
@@ -22,7 +22,7 @@ type BoringPoll struct {
// Internal signals and channels // Internal signals and channels
cancel context.CancelFunc cancel context.CancelFunc
done <-chan struct{} done *sync.WaitGroup
mutex sync.Mutex mutex sync.Mutex
} }
@@ -53,6 +53,7 @@ func (b *BoringPoll) Start() (runError <-chan error, err error) {
const logEveryBytes = 100 * 1000 * 1000 // 100 IEC MB const logEveryBytes = 100 * 1000 * 1000 // 100 IEC MB
var ready, done sync.WaitGroup var ready, done sync.WaitGroup
b.done = &done
ready.Add(len(b.urlToData)) ready.Add(len(b.urlToData))
done.Add(len(b.urlToData)) done.Add(len(b.urlToData))
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
@@ -166,7 +167,7 @@ func (b *BoringPoll) Stop() error {
return nil return nil
} }
b.cancel() b.cancel()
<-b.done b.done.Wait()
b.cancel = nil b.cancel = nil
b.done = nil b.done = nil
return nil return nil