limit number of goroutines for historic scanning as well (#761)

This commit is contained in:
Zachary Rice authored and GitHub committed 2022-01-07 08:58:47 -06:00
1 parent 44d7d89e19
commit 801d44a6e4
3 files changed
+13 -7

No files matched your search

+6 -2
View File
@@ -19,16 +19,20 @@ func FromGit(files <-chan *gitdiff.File, cfg config.Config, outputOptions Option
var findings []report.Finding
mu := sync.Mutex{}
wg := sync.WaitGroup{}
concurrentGoroutines := make(chan struct{}, MAXGOROUTINES)
commitMap := make(map[string]bool)
for f := range files {
// keep track of commits for logging
if f.PatchHeader != nil {
commitMap[f.PatchHeader.SHA] = true
}
wg.Add(1)
concurrentGoroutines <- struct{}{}
go func(f *gitdiff.File) {
defer wg.Done()
defer func() {
wg.Done()
<-concurrentGoroutines
}()
if f.IsBinary {
return
}