mirror of https://github.com/schollz/croc.git
avoid deadlock
This commit is contained in:
parent
35652e60a3
commit
80539f27c3
|
@ -98,17 +98,20 @@ func lookup(address string) (ipaddress string, err error) {
|
|||
if !INTERNAL_DNS {
|
||||
return localLookupIP(address)
|
||||
}
|
||||
result := make(chan string, len(publicDns))
|
||||
type Result struct {
|
||||
s string
|
||||
err error
|
||||
}
|
||||
result := make(chan Result, len(publicDns))
|
||||
for _, dns := range publicDns {
|
||||
go func(dns string) {
|
||||
s, err := remoteLookupIP(address, dns)
|
||||
if err == nil {
|
||||
result <- s
|
||||
}
|
||||
var r Result
|
||||
r.s, r.err = remoteLookupIP(address, dns)
|
||||
result <- r
|
||||
}(dns)
|
||||
}
|
||||
for i := 0; i < len(publicDns); i++ {
|
||||
ipaddress = <-result
|
||||
ipaddress = (<-result).s
|
||||
if ipaddress != "" {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue