Skip to content

Commit

Permalink
Use buffered channel and process all results
Browse files Browse the repository at this point in the history
  • Loading branch information
beautifulentropy committed Sep 27, 2024
1 parent 8dac30f commit bac0921
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions va/va.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ func (va *ValidationAuthorityImpl) performRemoteValidation(
err error
}

results := make(chan *rvaResult)
results := make(chan *rvaResult, len(va.remoteVAs))

for _, i := range rand.Perm(len(va.remoteVAs)) {
remoteVA := va.remoteVAs[i]
Expand All @@ -486,7 +486,9 @@ func (va *ValidationAuthorityImpl) performRemoteValidation(
bad := 0
var firstProb *probs.ProblemDetails

for res := range results {
for i := 0; i < len(va.remoteVAs); i++ {
res := <-results

var currProb *probs.ProblemDetails

if res.err != nil {
Expand Down Expand Up @@ -524,12 +526,6 @@ func (va *ValidationAuthorityImpl) performRemoteValidation(
firstProb.Detail = fmt.Sprintf("During secondary validation: %s", firstProb.Detail)
return firstProb
}

// If we somehow haven't returned early, we need to break the loop once all
// of the VAs have returned a result.
if good+bad >= len(va.remoteVAs) {
break
}
}

// This condition should not occur - it indicates the good/bad counts neither
Expand Down

0 comments on commit bac0921

Please sign in to comment.