subfetcher.loop: return earlier when the subfetcher is cancelled

This commit is contained in:
Jared Wasinger 2023-12-14 00:04:31 +08:00
parent 194d403e8e
commit 9d172df8bb

View file

@ -291,6 +291,9 @@ func (sf *subfetcher) loop() {
tasks := sf.tasks tasks := sf.tasks
sf.tasks = nil sf.tasks = nil
sf.lock.Unlock() sf.lock.Unlock()
if !keepRunning {
return
}
// Prefetch all tasks // Prefetch all tasks
for _, task := range tasks { for _, task := range tasks {
if _, ok := sf.seen[string(task)]; ok { if _, ok := sf.seen[string(task)]; ok {
@ -304,9 +307,5 @@ func (sf *subfetcher) loop() {
} }
sf.seen[string(task)] = struct{}{} sf.seen[string(task)] = struct{}{}
} }
if !keepRunning {
return
}
} }
} }