Skip to content

Commit

Permalink
release concurrent request semaphore before handling results
Browse files Browse the repository at this point in the history
Otherwise, the orchestrating goroutine may get stuck while trying to hydrate
more vulns. When this happens, it cannot proceed to read from errChan,
resulting in deadlock.

Signed-off-by: Spencer Schrock <[email protected]>
  • Loading branch information
spencerschrock committed Jun 27, 2024
1 parent 4fa2fa4 commit 3de69fb
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/osv/osv.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,12 @@ func HydrateWithClient(resp *BatchedResponse, client *http.Client) (*HydratedBat

go func(id string, batchIdx int, resultIdx int) {
vuln, err := GetWithClient(id, client)
rateLimiter.Release(1)
if err != nil {
errChan <- err
} else {
hydrated.Results[batchIdx].Vulns[resultIdx] = *vuln
}

rateLimiter.Release(1)
}(vuln.ID, batchIdx, resultIdx)
}
}
Expand Down

0 comments on commit 3de69fb

Please sign in to comment.