Skip to content

Commit

Permalink
Merge branch 'master' into staging-client
Browse files Browse the repository at this point in the history
  • Loading branch information
rod-hynes committed Aug 22, 2022
2 parents f3d1229 + cb4e5e2 commit 498b306
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions psiphon/common/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -838,11 +838,21 @@ func (r *Resolver) ResolveIP(
// arrived concurrent with the first answer. This receive avoids a race
// condition where inFlight may now be 0, with additional answers
// enqueued, in which case the following await branch is not taken.
select {
case nextAnswer := <-answerChan:
result.IPs = append(result.IPs, nextAnswer.IPs...)
result.TTLs = append(result.TTLs, nextAnswer.TTLs...)
default:
//
// It's possible for the attempts loop to exit with no received answer due
// to timeouts or cancellation while, concurrently, an answer is sent to
// the channel. In this case, when result == nil, we ignore the answers
// and leave this as a failed resolve.
if result != nil {
for loop := true; loop; {
select {
case nextAnswer := <-answerChan:
result.IPs = append(result.IPs, nextAnswer.IPs...)
result.TTLs = append(result.TTLs, nextAnswer.TTLs...)
default:
loop = false
}
}
}

// When we have an answer, await -- for a short time,
Expand Down

0 comments on commit 498b306

Please sign in to comment.