Describe the bug
In fetcher/idle.go lines 43-71, Stop() and StopAll() methods close stop channel, but:
- Multiple concurrent calls could attempt closing same channel
done channel read in StopAllAndWait() lacks synchronization
- Race condition if
Stop() and StopAll() called simultaneously
func (w *IdleWatcher) Stop() {
close(w.stop) // Panic if already closed
}
To reproduce
- Start IDLE watcher
- Call
Stop() twice concurrently
- Panic: "close of closed channel"
Expected behavior
Use sync.Once or check-then-close pattern:
type IdleWatcher struct {
stop chan struct{}
stopOnce sync.Once
// ...
}
func (w *IdleWatcher) Stop() {
w.stopOnce.Do(func() {
close(w.stop)
})
}
Screenshots
N/A
Additional context
- File:
fetcher/idle.go
- Lines: 43-50, 63-71
- Severity: Medium - panic on concurrent stop
- Fix complexity: Medium - add sync.Once pattern
Describe the bug
In
fetcher/idle.golines 43-71,Stop()andStopAll()methods closestopchannel, but:donechannel read inStopAllAndWait()lacks synchronizationStop()andStopAll()called simultaneouslyTo reproduce
Stop()twice concurrentlyExpected behavior
Use sync.Once or check-then-close pattern:
Screenshots
N/A
Additional context
fetcher/idle.go