summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--classic.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/classic.go b/classic.go
index ef138e2..bb22b0b 100644
--- a/classic.go
+++ b/classic.go
@@ -23,6 +23,7 @@ func classic(startURL url.URL, maxConcurrency, maxURLs int) {
ctx, cancel := context.WithCancel(context.Background())
var wg sync.WaitGroup
+ sema := make(chan struct{}, maxConcurrency)
loop:
for ; numPendingSends > 0; numPendingSends-- {
@@ -42,7 +43,9 @@ loop:
select {
case <-ctx.Done():
return
- case worklist <- getBatch(u):
+ case sema <- struct{}{}:
+ defer func() { <-sema }()
+ worklist <- getBatch(u)
}
})
}